-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
fix: display mismatch reasons in "following elements were mismatched" #1362
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,6 @@ class TextFeatureAssertionGroupFormatter( | |
parameterObject: AssertionFormatterParameterObject | ||
) : AssertionGroup by assertionGroup { | ||
override val description: Translatable = newName | ||
override val representation: Any = if(parameterObject.isNotInExplanatoryFilterGroup()) assertionGroup.representation else Text.EMPTY | ||
override val representation: Any = assertionGroup.representation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please revert in the end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be your suggestion then? Apparently, the current implementation in Atrium is "whatever is displayed in explanatory goes WITHOUT representation". That creates a deadlock, and I think it is wrong that "explanatory" implies "remove all representations". I just do not understand why it removes the representations. I believe the ones who want to display message "without representation" should call the relevant APIs "without representation", and it should not be "explanatory" that hides representations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The reason why we remove the representation is because usually we explain what expectation was defined without it being bound to a subject. For instance, the
I see now better where your request for a non-fluent assertionBuilder comes from :) I see overlapping topics here. I think one way forward would be that we can define that a certain Another approach would be that we allow more freely what bullet points are used and then you would not use an explanatory group in your case but just a regular list group with another bullet point. Have to go, wil, think about it later on. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to take the approach with escaping because otherwise we loose context. for this to work, we need:
I can give further pointers in case you want to tackle this. I am writing on top of my head, would need to take a closer look regarding the exact places and names. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import ch.tutteli.atrium.assertions.Assertion | |
import ch.tutteli.atrium.assertions.AssertionGroup | ||
import ch.tutteli.atrium.assertions.builders.* | ||
import ch.tutteli.atrium.core.Option | ||
import ch.tutteli.atrium.core.Some | ||
import ch.tutteli.atrium.core.getOrElse | ||
import ch.tutteli.atrium.creating.AssertionContainer | ||
import ch.tutteli.atrium.creating.Expect | ||
|
@@ -20,8 +21,10 @@ import ch.tutteli.atrium.logic.creating.iterable.contains.steps.impl.EntryPointS | |
import ch.tutteli.atrium.logic.creating.iterable.contains.steps.notCheckerStep | ||
import ch.tutteli.atrium.logic.creating.transformers.FeatureExtractorBuilder | ||
import ch.tutteli.atrium.logic.creating.typeutils.IterableLike | ||
import ch.tutteli.atrium.reporting.Text | ||
import ch.tutteli.atrium.reporting.translating.Translatable | ||
import ch.tutteli.atrium.reporting.translating.TranslatableWithArgs | ||
import ch.tutteli.atrium.translations.DescriptionBasic | ||
import ch.tutteli.atrium.translations.DescriptionBasic.NOT_TO_HAVE | ||
import ch.tutteli.atrium.translations.DescriptionBasic.TO_HAVE | ||
import ch.tutteli.atrium.translations.DescriptionIterableLikeExpectation.* | ||
|
@@ -135,9 +138,25 @@ class DefaultIterableLikeAssertions : IterableLikeAssertions { | |
|
||
val assertions = ArrayList<Assertion>(2) | ||
assertions.add(createExplanatoryAssertionGroup(container, assertionCreatorOrNull)) | ||
val mismatches = createIndexAssertions(list) { (_, element) -> | ||
mismatchIf(allCreatedAssertionsHold(container, element, assertionCreatorOrNull)) | ||
val mismatches = list.mapIndexedNotNull { index, e -> | ||
val assertion = if (assertionCreatorOrNull != null) { | ||
container.collectBasedOnSubject(Some(e as E), assertionCreatorOrNull) | ||
} else { | ||
// TODO: assertionCreatorOrNull should be non-nullable, and this "to be null" should be a part of expectation | ||
assertionBuilder.createDescriptive(DescriptionBasic.TO_BE, Text.NULL) { | ||
e == null | ||
} | ||
Comment on lines
+145
to
+148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is strange to handle There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, this functionality could be refactored. Is due to some legacy behaviour introduced in Atrium 0.2.0 or the like and wouldn't be necessary any more. Going to create a discussion about it |
||
} | ||
|
||
assertion.takeIf { mismatchIf(it.holds()) }?.let { | ||
assertionBuilder | ||
.feature | ||
.withDescriptionAndRepresentation(TranslatableWithArgs(INDEX, index), e) | ||
.withAssertion(it) | ||
.build() | ||
} | ||
Comment on lines
+141
to
+157
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should do the modification within createIndexAssertions and not here - I suggest you rename createIndexAssertions to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course, it should replace the current One of the takeaways, for now, is the current implementation shows both successful and failing assertions, and it does not distinguish between successful and failing ones. |
||
} | ||
|
||
if (mismatches.isNotEmpty()) assertions.add(createExplanatoryGroupForMismatches(mismatches)) | ||
|
||
decorateAssertion( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change this in the end, if you saw this text in reporting, then it is most likely an implementation bug 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, what is your recommendation then?
Currently, Atrium uses an explicit
None
subject in order to renderelements need all:
block.:atrium/logic/atrium-logic/src/commonMain/kotlin/ch/tutteli/atrium/logic/impl/containsHelpers.kt
Line 45 in 65227ad