I wanted to check the relationship between coverage and test suite effectiveness by creating a small test-suite out of master test suite by randomly picking the test-cases as described in this paper http://ift.tt/1YjpqFV and run the mutation test using pit for various sizes of test-suite. The SUT I am using is joda-time. I wrote the following program to create a small test-suite from master-suite
public class CustomTestAll extends TestCase {
public static Test suite() {
List<Test> inter_list;
List<Test> templist=new ArrayList<Test>();
TestSuite j=null;
Enumeration<Test> e;
TestSuite suite = new TestSuite();
//// TestHours
j= (TestSuite)TestHours.suite();
e=j.tests();
inter_list= Collections.list(e);
////TestDateTimeFieldType
j= (TestSuite)TestDateTimeFieldType.suite();
e=j.tests();
templist = Collections.list(e);
inter_list.addAll(templist);
////so on for all classes
///generating 10 unique random numbers between 0 and number of testcases
List<Integer> list = new ArrayList<Integer>();
for (int i=0; i<inter_list.size(); i++) {
list.add(new Integer(i));
}
Collections.shuffle(list);
for (int i = 0; i < 10;i++){
suite.addTest(inter_list.get(list.get(i)));
}
Enumeration<Test> k=suite.tests();
while(k.hasMoreElements()){System.out.println(k.nextElement());}
return suite;
}}
This is running fine with junit and emma code coverage . However when I run mutation testing (pitest)using this test-suite, it is taking all the test-cases in a class instead of one selected. I am not able to figure what is wrong. I am a beginner in java and I am using eclipse.
Aucun commentaire:
Enregistrer un commentaire