1

Simply can't find a concrete example where a db connection is mocked. Preferred with Mockito.

public Connection getCon() throws SQLException, Exception {
        Properties login = new Properties();

        TimeZone timeZone = TimeZone.getTimeZone("GMT+2:00");
        TimeZone.setDefault(timeZone);

        Connection conn = null;
        conn = DriverManager.getConnection(url, username, password);

        return conn;
}

Want to test this method...

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
basti
  • 41
  • 3

1 Answers1

1

All you need is to mock static class DriverManager. Here is an answer to exactly your issue: Mocking static methods with Mockito

Misha Lemko
  • 591
  • 4
  • 9