-2
내 코드에서 단위 테스트
expected:<interface java.sql.Connection> but was:<class com.mysql.jdbc.JDBC4Connection>
는 경고 메시지를 이해 할 수 없습니다 <인터페이스 java.sql.Connection에>하지만했다 : <클래스 com.mysql.jdbc.JDBC4Connection>
에서이 메시지를 받고 있습니다
:
public class ConnectionManager {
@SuppressWarnings("unused")
public static Connection createConnection() throws SQLException {
String url = "jdbc:mysql://localhost:3306/library";
String name = "root";
String password = "root";
Connection connection = null;
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(url, name, password);
} catch (ClassNotFoundException e) {
if (connection != null){
connection.close();
}
throw new SQLException(e);
}
return connection;
}
}
내 코드에 어떤 문제가 : 연결을 얻기를위한
@Test
public void connectionTest() throws SQLException{
Connection conn = ConnectionManager.createConnection();
assertEquals(Connection.class, conn.getClass());
conn.close();
}
내 모의 수업?
품질 필터를 우회하지 마십시오. – SLaks
왜 컴파일러를 테스트하고 있습니까? – SLaks