当 CodePro 自动为我的方法生成测试时,它通常会生成相同的测试:
/**
* 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);
}
这些是对以下方法的测试:
public String getCategoryID() throws IOException,
NoCategoryMatchException {
categoryID = retrieveCategoryID();
if (categoryID.equals("")) {
throw new NoCategoryMatchException();
}
return categoryID;
}
我使用 CodePro 错了吗?我认为多个测试是我实现两个测试的提示,但是每当我自定义测试时,它们只会在 CodePro 重新生成测试时被重写。