News for hackers. Stuff that matters.
Re:Best Practices for Testing in Java (2019) by splittingTimes on Tuesday September 01, 2020 @07:02PM (#24348136)
To easily see in test failures what went wrong we follow the naming convention:

UnitOfWorkUnderTest_Scenario_ExpectedBehavior

Which mimics the internal GWT structure.

Re:Best Practices for Testing in Java (2019) by joshka on Wednesday September 02, 2020 @02:39PM (#24356339)
I have suggested the same previously, but the display name approach is better. Now test names should be short:

    @DisplayName("throws IllegalArgumentException when given bad data")
    void badData() {
Re:Best Practices for Testing in Java (2019) by hackerm0nkey on Wednesday September 02, 2020 @09:04AM (#24352793)
I love this. I started with trying to have simple, short and descriptive names for the test methods but then it doesn't work quite well with more complicated test cases. So I grew to like something along these lines:

given_someInput_someOtherInput_when_doX_then_thisThingHappen_thatThingHappen

which has the advantage to be optimised for reading. When I want to skim over the test class quickly I can simply look at the method names to get an idea on what the test is doing and if I want more details I can look further at it's implementation