Are there any standard unit test batteries for the standard interfaces? (IDictionary<K,V>, etc) #52528
Replies: 1 comment
-
Right now I'm working at it - but indeed I'm not a test code writer :( I'm still looking for Open Source Unit tests for those standard interfaces. Anyway, how/why would you implement tests for those? Most of the interfaces are generic, and depending on the tests you would require a specialized test data set which can fit the tests requirements. For that reason I wrote only very basic tests which don't rely on the test data too much. I think that's maybe the way to go: Use only basic tests for interfaces and write specialized tests for types. However, I couldn't even find basic tests to adopt for interfaces like Maybe you can get some ideas from my repository. The tests I wrote are in the |
Beta Was this translation helpful? Give feedback.
-
(I would have posted this to StackOverflow but as I'm asking for a resource or recommendation this question would violate SO's rules against posts asking for recommendations and resources)
I found myself implementing
IDictionary<TKey,TValue>
(IDictionary
for short, I'm not referring to the legacy non-generic interface) and as part of TDD I need to write unit tests for my implementation, and it wouldn't be a good use of my time to write my own unit tests for my implementation ofIDictionary
as it would be identical to any existing test for the standard functionality ofIDictionary
, so I searched around for some standard, reusable test-cases forIDictionary
, but I couldn't find anything like a copy+paste battery of pre-written unit-tests or NuGet package with the test-cases built-in. The closest I found was this, but seems specific to someone's own projects.I took a look at the official .NET tests for the generic collections but they seem to be for their specific concrete types, rather than reusable tests for each collection interface - and this obviously doesn't concern the non-collection interfaces that should also be tested when reimplemented, such as
IEquatable<T>
andIComparer<T>
.What do you do when you need to unit-test types implementing standard interfaces?
Beta Was this translation helpful? Give feedback.
All reactions