如何找到重复的 JUnit 测试

huangapple 未分类评论46阅读模式
英文:

How to find duplicate junit tests

问题

有办法找到重复的测试以清理多余的测试吗?

解释如下:

public class Sut {
    public void method() {}
    public void methodB() {}
    public void methodC() {}
}

public class TestA {
    public void testMethod() {}
    public void testMethodB() {}
}

public class TestB {
    public void testMethodblablahB() {} // 它的代码集与 testMethodB() 不同
    // 但它覆盖了 methodB 的相同代码
    public void testMethodC() {}
}

从代码 testMethodblablahB 来看,也许不会立即明显,testMethodBtestMethodblahblah 都为 methodB 提供了相同的覆盖率。我可能可以通过使用纸笔分析或调试来做到这一点。

有没有自动确定这一点的方法?也许可以使用某种图算法?

英文:

Is there way to find duplicate tests to clean up redundant tests?

To explain:

public class Sut {
    public void method() {}
    public void methodB() {}
    public void methodC() {}
}

public class TestA {
    public void testMethod() {}
    public void testMethodB() {}
}

public class TestB {
    public void testMethodblablahB() {} // it has a different set of code other than testMethodB() 
// but it covers the same code of methodB
    public void testMethodC() {}
}

from the code testMethodblablahB, it might not be immediately obvious both testMethodB and testMethodblahblah, gives the same coverage for the methodB. I can probably do that by analyzing using pen/paper or debugging.

Is there any automated way of determining this? May be some sort of graph algorithm?

huangapple
  • 本文由 发表于 2020年4月10日 12:50:08
  • 转载请务必保留本文链接:https://java.coder-hub.com/61134217.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定