expekt
expekt copied to clipboard
Lambda-based assertions for collections
Borrowing from Fluent Assertions, it would be quite convenient to have lambda-based assertions for collections:
class Thing(val name)
val collection = arrayListOf(Thing("a"), Thing("b"), Thing("c"))
collection.should.contain({ it.name == "a" })
Currently it's possible to replicate this using list extensions, but it is not as readable, and will not give as descriptive message:
collection.firstOrNull({ it.name == "a" }).should.not.be.`null`