英文:
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
来看,也许不会立即明显,testMethodB
和 testMethodblahblah
都为 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?
专注分享java语言的经验与见解,让所有开发者获益!
评论