I want to implement a database reader using Spring and JDBC.
@Component
public class MyReader() {
public void read() {
/* Other code */
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
String myDbValue = rs.getString("myColumn");
}
/* Other code */
}
}
I want to test the behavior of my class, if column myColumn
isn't present.
One solution would be to move the constant myColumn
to a private method, but some guys on SO told other users, that mocking private methods smells, see Raedwalds comment and I would agree.
I could also mock the database file itself, but mocking files isn't a good way too.
Any ideas how handle this issue?