Hi,

Was just looking at some of the new tests and just wondering if they are trying 
to be a bit too clever? What do other people think?

For instance this:

@Test
public void testOfWintime() throws Exception {
    assumeThat(clazz, isOneOf(TimeStamp.class));
    {
        Method ofMethod = clazz.getDeclaredMethod("ofWinTime", 
BigInteger.class);
        ofMethod.invoke(null, BigInteger.valueOf(1));
    }
    {
        Method ofMethod = clazz.getDeclaredMethod("ofWinTime", String.class);
        ofMethod.invoke(null, "1");
    }
    {
        Method ofMethod = clazz.getDeclaredMethod("ofWinTime", long.class);
        ofMethod.invoke(null, 1L);
    }
}

Could be replaced with 3 asserThat calls calling TimeStamp.ofWinTime and as a 
bonus actually test that the class is correctly initialised :-)

IMO tests are part of the documentation and should be easy to read and you 
shouldn’t have to think that hard about them and as a bonus if they are easy to 
read people are more likely to contribute to them.

Thanks,
Justin


Reply via email to