Support for loose collection validation in a Java unit testing framework
Any Java unit testing framework that supports writing unit testing code like this:
Collection<AType> myCollection = objectUnderTest.doSomething();
assertCollectionContainsAtleast(myCollection, "a Expected value");
Meaning what I would like is some sort of iteration support with some sort of开发者_运维技巧 matcher attached.
Take a look at Hamcrest, which contains assertions for many things, including collections. You can use hasItem
, hasKey
, hasValue
etc.
You might also take a look at Unitil's assertion utilities.
精彩评论