pieTest - 突变测试失败

pieTest - Mutation Test failure

提问人:RagaSGNur 提问时间:7/26/2022 更新时间:7/27/2022 访问量:272

问:

总而言之,运行突变测试用例时存在问题。

获取突变测试用例失败,如下所示:

删除了对 java/util/List::sort 的调用 → SURVIVED 删除了对 java/util/List::forEach 的调用 → SURVIVED

代码:

List<CustomClass> data;//address is the field in the CustomClass
UseCase useCase; //setEventBus is the method
   data.sort(Comparator.comparingInt(CustomClass::getAddress));
     
   data.forEach(frame -> useCase.setEventBus(frameList, data.getAddress()));

我写了几个单元测试用例,但突变体幸存下来。谁能在这里帮忙解决这个问题?

java spring-boot junit5 spring-test 突变测试

评论

0赞 Timo 7/26/2022
我还做了突变测试的第一步,所以这只是一个猜测:你的测试仍然是绿色的,即使从代码中删除了 and。编写一个测试,当您删除其中一个调用时,该测试将失败。sortforEach

答:

0赞 RagaSGNur 7/27/2022 #1

解决了失败的突变情况。

删除了对 java/util/List::sort 的调用→ SURVIVED:

为以下行添加了测试用例 data.sort(Comparator.comparingInt(CustomClass::getAddress)); 添加测试用例以将未排序的数据存储在“data”对象中。