That test could be improved

The following snippet of a fresh test, generated by a fresh version of Diffblue plugin (as can be seen by that fancy method-name), might not be theultimate way to test it.
First, it generates a test of two fresh, mint BaseProducts, using the equals() method, and then it does not check the result of this, but delegates that to one of the standard assert-methods, which most likely repeats the call to the BaseProduct.equals() method.

IMO, either ‘// Act’ part can be omitted or the ‘// Assert’ is changed to use that result of the first test.

    /**
     * Method under test: {@link BaseProductBean#equals(Object)}
     */
    @Test
    void testEquals_whenOtherIsEqual_thenReturnEqual() {
        // Arrange
        BaseProductBean baseProductBean = new BaseProductBean();
        BaseProductBean baseProductBean2 = new BaseProductBean();

        // Act
        boolean actualEqualsResult = baseProductBean.equals(baseProductBean2);

        // Assert
        assertEquals(baseProductBean, baseProductBean2);
    }

1 Like

Hi @dvholten

Thank you for sharing this example and suggestion, we are always looking for helpful feedback such as this to help drive improvements. This has been shared with our engineers.

Kind Regards,
Shaun