我正在写一个包含常见的数据结构的几个专门实施一个类库(列表,集,字典...)。我发现自己总在写同一单元测试一遍又一遍,我从来不相信我不会忘记测试一些重要的场景。
I'm writing a class library that contains several specialized implementations of common data structures (lists, sets, dictionaries...). I find myself always writing the same unit tests over and over, and I'm never sure I'm not forgetting to test some important scenarios.
由于我的班级都实现了标准接口(的IList< T>
,的IDictionary< K,V>
等),我想知道是否有某种这些接口的所有实现应该通过引用的单元测试。当然,我还需要测试我的课的具体问题,但至少我会更加有信心,有没有在我的实现标准接口坏了。
Since my classes all implement standard interfaces (IList<T>
, IDictionary<K,V>
, etc), I was wondering if there were some kind of "reference" unit tests that all implementations of these interfaces should pass. Of course I would also need to test the specific aspects of my classes, but at least I would be more confident that there is nothing broken in my implementation of the standard interfaces.
您可以看看在Mono Github上单元测试 - 至少有词典
和的IList
测试已经有
You could have a look at the Mono unit tests on Github - there is at least Dictionary
and IList
tests there already.