Menu

#67 new Junit rule - duplicate literal within a test method

open
nobody
None
5
2013-02-16
2010-11-10
No

new Junit rule - duplicate literal within a test method.
You should create a local variable or constant.
This is a variation on the duplicate literal and number but a little more specific.
passes:
@Test
public void testTestObject() throws Exception {

int eventKey = 111;
int partnerKey = 222;
def x = new MyObject(eventKey, partnerKey);
assertEquals(eventKey, x.y());
assertEquals(eventKey, x.z());
}

fails:
passes:
@Test
public void testTestObject() throws Exception {

def x = new MyObject(111, 222);
assertEquals(111, x.y());
assertEquals(222, x.z());
}

Discussion


Log in to post a comment.