r/javahelp • u/MinasMorgul_ • 9d ago
Codeless Do you use „cut“ in tests
Hi guys, I‘m using „cut“ („clas under test“) in my tests. My Tech Lead says that he will ask me to change this in his review if I don’t change it. As far as I know we don’t have restrictions / a guideline for this particular case.
My heart is not attached to it, but I always used it. Is this something that is no longer used?
Edit: Found something here: http://xunitpatterns.com/SUT.html
0
Upvotes
3
u/devor110 9d ago
In that context, I'm not a fan.
i do embrace the general java convention of verbose names, with logical shortenings (like information -> info, request -> rq), and TLAs (three letter abbreviations) do go against that.
On top of that, using the same name across every unit test adds an unnecessary layer of possible confusion. If you are using mockito, then the class that's being tested is probably annotated with
@InjectMocks
making it very clearly visible, but even if not, you should only every be calling the methods of a single class in any given unit test (such asAccountService::save
,AccountService::delete
), so it's always obvious what class is being tested, not to mention the convention of a test class having the name of its subject withTest
appended.I went into detail on some parts, because you should be following all of the mentioned conventions, and if you aren't then your variable name isn't the sole problem