When CodePro automatically generates tests for my methods, it often generates identical tests:
/**
* Run the String getCategoryID() method test.
*
* @throws Exception
*
* @generatedBy CodePro at 17/11/11 11:44 AM
*/
@Test
public void testGetCategoryID_1()
throws Exception {
Category fixture = new Category("");
String result = fixture.getCategoryID();
// add additional test code here
// An unexpected exception was thrown in user code while executing this test:
// java.lang.NullPointerException
// at java.io.StringReader.<init>(StringReader.java:33)
// at xpath.XPathRunner.<init>(XPathRunner.java:23)
// at trademefacade.Category.retrieveCategoryID(Category.java:95)
// at trademefacade.Category.getCategoryID(Category.java:68)
assertNotNull(result);
}
/**
* Run the String getCategoryID() method test.
*
* @throws Exception
*
* @generatedBy CodePro at 17/11/11 11:44 AM
*/
@Test
public void testGetCategoryID_2()
throws Exception {
Category fixture = new Category("");
String result = fixture.getCategoryID();
// add additional test code here
// An unexpected exception was thrown in user code while executing this test:
// java.lang.NullPointerException
// at java.io.StringReader.<init>(StringReader.java:33)
// at xpath.XPathRunner.<init>(XPathRunner.java:23)
// at trademefacade.Category.retrieveCategoryID(Category.java:95)
// at trademefacade.Category.getCategoryID(Category.java:68)
assertNotNull(result);
}
These are tests for the following method:
public String getCategoryID() throws IOException,
NoCategoryMatchException {
categoryID = retrieveCategoryID();
if (categoryID.equals("")) {
throw new NoCategoryMatchException();
}
return categoryID;
}
Am I using CodePro wrong? I thought the multiple tests were hints for me to implement two tests, but whenever I customise the tests, they just get rewritten when CodePro regenerates the tests.