Konstantin
Konstantin

Reputation: 3696

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.

Upvotes: 0

Views: 154

Answers (2)

cwash
cwash

Reputation: 4245

You might also take a look at Unitil's assertion utilities.

Upvotes: 0

Brian Agnew
Brian Agnew

Reputation: 272357

Take a look at Hamcrest, which contains assertions for many things, including collections. You can use hasItem, hasKey, hasValue etc.

Upvotes: 5

Related Questions