Michu93
Michu93

Reputation: 5687

Is testing everything a good approach?

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

Answers (1)

GhostCat
GhostCat

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

Related Questions