1
我正在測試兩個準備好的語句,如下所示,我希望它使用assertEquals表明它們是相同的,但是它拋出了一個錯誤,表明result和expectedResult是不等於。Junit使用assert方法比較兩個預準備語句
public PreparedStatement setSQL(String sql) throws SQLException {
try {
pst = connection.prepareStatement(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return pst;
}
public void testSetSQL() throws SQLException {
String sql = "SELECT * FROM student INNER JOIN member ON student.ssn=member.ssn WHERE ssn = ?";
result = dbconn.setSQL(sql);
// expsql = ;
expectresult = connection.prepareStatement("SELECT * FROM student INNER JOIN member ON student.ssn=member.ssn WHERE ssn = ?");
assertSame(expectresult, result);
一個新的默認PreparedStatement對象無處是'PreparedStatement'記載有值相等語義。 –