https://kotlinlang.org logo
#test
Title
# test
p

poohbar

12/16/2020, 9:23 PM
I am looking for a library similar to https://github.com/MarkusAmshove/Kluent that would let me specify custom assert messages. So that when the test fails, it’s a bit more descriptive than
Expected true but got false
l

LeoColman

12/16/2020, 10:22 PM
Maybe #kotest with
withClue
?
p

poohbar

12/16/2020, 10:55 PM
Kotest replaces JUnit?
maybe i could just use the assertions sub-project
d

dave08

12/17/2020, 3:37 AM
Or #strikt
👍 1
d

Daniel

12/17/2020, 8:22 AM
Good old assertJ works as well
c

christophsturm

12/17/2020, 11:31 AM
if you need only assertions i would recomment #strikt
👍 1
p

poohbar

12/17/2020, 3:03 PM
hmm. I don’t like that #strikt does not use
infix
for assertions
it doesn’t read as nice
d

dave08

12/17/2020, 5:34 PM
Each one with their preferences, I don't like infixes, they spill tons of top level funs into my code complete...
Even when not trying to write assertion code...
a

audriusk

12/18/2020, 2:47 PM
There is also Atrium It's multiplatform assertions library for Kotlin. It will do everything you want. Very powerful... Maybe even too much over-engineered 🤔
r

robstoll

12/21/2020, 1:22 PM
@poohbar let me know in case you should try out Atrium. Feedback for the infix API is appreciated
p

poohbar

12/22/2020, 2:55 AM
@robstoll I would recommend working on the readme a bit. Structuring it a bit better and maybe making it shorter. The library itself looks super powerful, but maybe too powerful for my needs. And it's again missing my most desired feature which is fluent assertions:
expected shouldEqual actual
just reads so naturally 🙂
r

robstoll

12/22/2020, 12:26 PM
Suggestions about a different structure are welcome, any idea? Note that the README is using the api-fluent and not the api-infix. You see examples of the api-infix version here: https://github.com/robstoll/atrium/blob/master/apis/differences.md For instance, you would write:
Copy code
expect(1) toBe 2
expect(listOf(1,2)) toBe empty
expect("hello Robert") contains o ignoring case notOrAtMost 1 the regexPatterns("h(e|a)llo", "[Rr]obert")