Kiedy CodePro automatycznie generuje testy dla moich metod, to często generuje identyczne testy:Dlaczego program google CodePro generuje identyczne testy JUnit?
/**
* 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);
}
Są to testy dla następującej metody:
public String getCategoryID() throws IOException,
NoCategoryMatchException {
categoryID = retrieveCategoryID();
if (categoryID.equals("")) {
throw new NoCategoryMatchException();
}
return categoryID;
}
używam CodePro źle? Wydaje mi się, że testy wielokrotne były dla mnie wskazówką do wdrożenia dwóch testów, ale za każdym razem, gdy dostosowuję testy, są one po prostu przepisywane, gdy CodePro ponownie generuje testy.
Czy możesz opublikować kod, dla którego są to testy? –
Przepraszam za opóźnienie, gotowe. – Kevin