-
-
Notifications
You must be signed in to change notification settings - Fork 229
Closed
Milestone
Description
Platform (all, jvm, js): all
Extension (none, kotlin 1.3): none
Code related feature
Say you have used assertJ in your project and would like to migrate to Atrium. To allow that one can migrate step by step to Atrium it would be nice if someone could write:
expect(person) {
feature(Person::age).toBeGreaterThan(40)
toHoldThirdPartyExpectation("to have", "grandsons") { subject ->
assertThat(subject).hasGrandsons()
}
}
And then in reporting we would see something along the lines of (imagine we would show all expectations):
I expected subject: Person(..., children=...)
* -> age: 56
to be greater than: 40
* to have: grandsons
!! expectation failed, thrown exception:
ℹ Properties of the unexpected org.opentest4j.AssertionFailedError
» message: "expected: 2
but was: 1" <1234789>
» stacktrace:
⚬ org.atriumlib.ToHoldThirdPartyExpecationTest$1$7$1.invoke(ToHoldThirdPartyExpecationTest.kt:67)
⚬ org.atriumlib.ToHoldThirdPartyExpecationTest$1$7$1.invoke(ToHoldThirdPartyExpecationTest.kt:22)
⚬ org.atriumlib.ToHoldThirdPartyExpecationTest$1$7.invoke(ToHoldThirdPartyExpecationTest.kt:280)
⚬ org.atriumlib.ToHoldThirdPartyExpecationTest$1$7.invoke(ToHoldThirdPartyExpecationTest.kt:22)
One can currently achieve more or less the same using subject-changer but it requires already quite a bit of knowledge of _logic-level API
expect(person) {
_logic.changeSubject.reportBuilder()
.withDescriptionAndRepresentation(
"to have",
"grandsons",
).withTransformation {
Some { 1 }
}
.withDefaultFailureHandler()
.build()
.transformAndAppend {
notToThrow()
// dummy expectation, we need one as not defining one would throw as well
// but this shows up in case of an error which isn't nice at all
.toBeAnInstanceOf<Any>()
}
}
And it would show up differently in reporting