Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for soft assertions #178

Closed
igorwojda opened this issue Jun 18, 2020 · 4 comments
Closed

Add support for soft assertions #178

igorwojda opened this issue Jun 18, 2020 · 4 comments

Comments

@igorwojda
Copy link

Similar to assertSoftley
https://twitter.com/kotlintesting/status/1267350165750308864

@MarkusAmshove
Copy link
Owner

Hi igor,

would you like to propose a draft on how this could work in Kluent?

The most important things in this are, in my opinion, that all assertions are run (no matter if some fail) and that there is a unified failure message.
I like the way Shouldly does this, including the aggregated error messages.

The way our assertions are currently built, the method would actually have to take vararg functions to accomplish this, like so:

person.assertAll(
    { it.name.shouldBe("Name") },
    { it.age.shouldBe(18) }
)

that way assertAll can wrap all assertions, catch their errors and aggregate the messages.

What do you think?

@igorwojda
Copy link
Author

igorwojda commented Jun 23, 2020

  1. Yes fail of single assertion should not abort the execution (idea behind soft assertion)
  2. other factor that we should also consider is the fact that we may want verify data from more then one object.
  3. I am not a big fan off these nested lambdas (kotest works without them)
shouldAssertSoftley {
	sut.name.shouldBe("Name")
    sut.age.shouldBe(18)
}

Also we could probably keep should prefix to match rest of kluent assertions
shouldAssertSoftly / shouldAssertAll

@MarkusAmshove
Copy link
Owner

Do you want to give the implementation following your design a shot? 😊

drcolombo added a commit to drcolombo/Kluent that referenced this issue Nov 17, 2020
MarkusAmshove added a commit that referenced this issue Dec 27, 2020
#178: added support for assertSoftly
@MarkusAmshove
Copy link
Owner

This is now part of version 1.65 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants