<分区>
我可以专门插入我的 Set 和 ListIterator 实现的测试。
<分区>
我可以专门插入我的 Set 和 ListIterator 实现的测试。
最佳答案
Guava在 guava-teSTLib
组件中有一组 TestSuiteBuilders
,它们一起为给定的集合实现生成几百到几千个测试用例。例如,你可能会写这样的东西
public static Test suite() {
return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override protected Set<String> create(String[] elements) {
return ImmutableSet.copyOf(elements);
}
})
.named("ImmutableSet");
.withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_QUERIES)
.createTestSuite();
}
这会为 Set
实现生成一个完整的、极其详尽的测试用例集。
它没有尽可能完整地记录,但它会给你一个非常详尽的测试套件。
关于java - 是否有任何公开可用的 Java 集合单元测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12023734/