我写了一个工厂来生产java.sql.Connection
件物品:
public class MySQLDatabaseConnectionFactory implements DatabaseConnectionFactory {
@Override public Connection getConnection() {
try {
return DriverManager.getConnection(...);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
我想验证传递到DriverManager.getConnection
的参数,但我不知道如何模拟静态方法.我在测试用例中使用JUnit4和Mockito.有没有好的方法来模拟/验证这个特定的用例?