-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
More consise reporting for contains.atLeast(1) #934
More consise reporting for contains.atLeast(1) #934
Conversation
...GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionCharSequenceAssertion.kt
Outdated
Show resolved
Hide resolved
...-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionIterableAssertion.kt
Outdated
Show resolved
Hide resolved
...in/ch/tutteli/atrium/logic/creating/basic/contains/creators/impl/ContainsAssertionCreator.kt
Outdated
Show resolved
Hide resolved
...GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionCharSequenceAssertion.kt
Outdated
Show resolved
Hide resolved
...GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionCharSequenceAssertion.kt
Outdated
Show resolved
Hide resolved
...-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionIterableAssertion.kt
Outdated
Show resolved
Hide resolved
...-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionIterableAssertion.kt
Outdated
Show resolved
Hide resolved
5fa67a1
to
f3a01ab
Compare
Codecov Report
@@ Coverage Diff @@
## master #934 +/- ##
==========================================
+ Coverage 91.33% 91.34% +0.01%
==========================================
Files 429 429
Lines 4280 4299 +19
Branches 215 219 +4
==========================================
+ Hits 3909 3927 +18
- Misses 322 323 +1
Partials 49 49
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
...in/ch/tutteli/atrium/logic/creating/basic/contains/creators/impl/ContainsAssertionCreator.kt
Outdated
Show resolved
Hide resolved
...utteli/atrium/logic/creating/basic/contains/creators/impl/ContainsObjectsAssertionCreator.kt
Outdated
Show resolved
Hide resolved
...in/ch/tutteli/atrium/logic/creating/basic/contains/creators/impl/ContainsAssertionCreator.kt
Outdated
Show resolved
Hide resolved
): AssertionGroup { | ||
val count = search(multiConsumableContainer, searchCriterion) | ||
val featureAssertion = featureFactory(count, descriptionNumberOfOccurrences) | ||
val mismatchedAssertions = mismatches(multiConsumableContainer, searchCriterion) | ||
val assertions = if (searchBehaviour is NotSearchBehaviour) { | ||
listOfNotNull(createExplanatoryGroupForMismatches(mismatchedAssertions)) |
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.
IMO listOfNotNull is wrong here as we don't want an emptyList / assertions
should be a non-empty list in the end. If you move the call of mismatches inside the if then you can change createExplanatoryGroupForMismatches
back to return an AssertionGroup
You need to adjust InAnyOrderEntriesAssertionCreator so that you only call createExplanatoryGroupForMismatches if mismatches is not empty, but there it makes sense because we always have two assertions in the list, so we will never have an empty list
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.
I see, I didn't realize assertions had to be a non-empty list. When there are no sub-assertions in the list, it seems that we would rather return a descriptive assertion: assertionBuilder.createDescriptive(groupDescription, searchCriterion, trueProvider).build()
? However we may need to wrap the descriptive assertion in an invisibleGroup
since the searchAndCreateAssertion
requires an AssertionGroup
and not an Assertion
.
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.
I guess it would be the simplest if we already implement the bonus you describe above. Then we don't need that featureFactory returns AssertionGroup?
but can again return AssertionGroup
and we escape the null-hell 😆
Isn't it?
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.
Yes, it seems so!
...utteli/atrium/logic/creating/basic/contains/creators/impl/ContainsObjectsAssertionCreator.kt
Outdated
Show resolved
Hide resolved
...i/atrium/logic/creating/iterable/contains/creators/impl/InAnyOrderEntriesAssertionCreator.kt
Outdated
Show resolved
Hide resolved
...i/atrium/logic/creating/iterable/contains/creators/impl/InAnyOrderEntriesAssertionCreator.kt
Outdated
Show resolved
Hide resolved
...m-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultIterableLikeAssertions.kt
Outdated
Show resolved
Hide resolved
logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/containsHelpers.kt
Outdated
Show resolved
Hide resolved
05324bf
to
9fb65a9
Compare
Sorry about the recent force-push, I believe I meant to I've made the changes you requested, and I'm fairly sure everything works but I want to point out that the explanatory assertion in the "happy case" is never tested, and I'm not sure how to go about testing those cases. |
...-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionIterableAssertion.kt
Outdated
Show resolved
Hide resolved
...CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionCharSequenceAssertion.kt
Outdated
Show resolved
Hide resolved
No worries about the force push. I am going to write the happy case and assign you as reviewer. This way you will see how it can be accomplished |
…otlin/ch/tutteli/atrium/translations/DescriptionCharSequenceAssertion.kt
…otlin/ch/tutteli/atrium/translations/DescriptionIterableAssertion.kt
@wordhou thanks for this contribution. You are on 🔥 continue like that the Atrium users will be thankful 🙂 |
Resolves #310.
Modifies
featureFactory
inContainsAssertionCreator
to display ano such item was found
text instead of a verbose feature assertion about the number of occurrences, specifically in the casecontains.atLeast(1)
. Creates adescriptionNotFound
abstract property on theContainsAssertionContainer
that gets overrode in its subclasses to provide the description forbut no such item was found
.I created three new translatables for when an entry is not found, a value is not found, and a charSequence is not found (however they could all be the same if we chose).
I confirm that I have read the Contributor Agreements v1.0, agree to be bound on them and confirm that my contribution is compliant.