Khi CodePro tự động tạo ra các bài kiểm tra cho các phương pháp của tôi, nó thường tạo ra các bài kiểm tra giống hệt nhau:Tại sao google CodePro tạo ra các kiểm tra JUnit giống hệt nhau?
/**
* 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);
}
Đây là những thử nghiệm về phương pháp sau:
public String getCategoryID() throws IOException,
NoCategoryMatchException {
categoryID = retrieveCategoryID();
if (categoryID.equals("")) {
throw new NoCategoryMatchException();
}
return categoryID;
}
Tôi có sử dụng CodePro sai? Tôi nghĩ rằng nhiều thử nghiệm là gợi ý cho tôi để thực hiện hai bài kiểm tra, nhưng bất cứ khi nào tôi tùy chỉnh các bài kiểm tra, họ chỉ được viết lại khi CodePro tái tạo các bài kiểm tra.
Bạn có thể đăng mã cho những thử nghiệm này không? –
Xin lỗi vì đã trì hoãn. – Kevin