I have a method. What is the best practice to unit testing? You can make a mock Connection and ResultSet and pass as a method parameter as an object but I find it stupid, unprofessional solution.
public static void playA() { MyObject object = check("cat"); // some stuff... } private static MyObject check(String s) throws SQLException { // some stuff checking string MyObject o = methodA(s); // some stuff doing on the object return o; } private static MyObject methodA(String s) throws SQLException { Connection c = MySettings.getConnection(); PreparedStatement ps = c.prepareStatement("select * from Objects where type = ?"); ps.setString(1, s); ResultSet resultSet = ps.executeQuery(); while (resultSet.next()) { // mapping return object; } return null; }