I have the following method to test in Junit
public static boolean saveLocationData(String student, String city, String location){
boolean status=false;
try {
Connection mySqlConn = MySQLConn.getConnection();
String mySqlQuery = "INSERT INTO locations VALUES ( ?, ?, ?)";
PreparedStatement preparedStatement = mySqlConn.prepareStatement(mySqlQuery);
preparedStatement.setString(1, student);
preparedStatement.setString(2, city);
preparedStatement.setString(3, location);
preparedStatement.execute();
} catch (Exception exception){
/////
}
return status;
}
And the testing I have tried is :
final void saveLOCATIONData() {
boolean validation = LocationDao.saveLocationData("student", "nyc", "usa");
assertTrue(validation);
//doesn’t exist
validation = LocationDao.saveLocationData("example", "example", "example");
assertFalse(validation);
}
When I run the test it says that the expected value should be true, instead is false, while this is the actual data that I have in the database. What can be causing the problem?
Aucun commentaire:
Enregistrer un commentaire