Reputation: 5687
I have class Generator
with a method buildDocument
and inside this method there is:
service.getDocument() + EXTENSION;
where private final static String EXTENSION = ".txt";
method getDocument()
is already tested in ServiceTest
class. Should I add test for buildDocument
method to test this file extension adding? It seems a bit like testing:
private boolean method(){
return true;
}
should such methods be tested?
Upvotes: 1
Views: 59
Reputation: 140427
Note that your method is private. Anything that is private should be considered an implementation detail. Thus you rather avoid writing a unit test for just that part.
Meaning: if you have test method somewhere already that your document sits in the right place, with the expected name (which would include the extension), then you are "good enough".
But note this also a bit of "personal style".
Upvotes: 3