You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by Justin Mclean <ju...@classsoftware.com> on 2018/02/20 00:12:23 UTC
WET vs DRY tests
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
Re: WET vs DRY tests
Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,
> Have to agree that I am having problems to understand what the thing does. But that might be related to me not having had my first coffee if the day yet ;-)
Once you look at the code it’s testing it become clearer but the mental effort required seem a bit high for a simple test. Other people smarter than me may of course have no issue with it at all :-)
Thanks,
Justin
Re: WET vs DRY tests
Posted by Christofer Dutz <ch...@c-ware.de>.
Have to agree that I am having problems to understand what the thing does. But that might be related to me not having had my first coffee if the day yet ;-)
Chris
Outlook for Android<https://aka.ms/ghei36> herunterladen
________________________________
From: Justin Mclean <ju...@classsoftware.com>
Sent: Tuesday, February 20, 2018 1:12:23 AM
To: dev@plc4x.apache.org
Subject: WET vs DRY tests
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