mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
Make notToContain less verbose and show mismatched indices (#931)
This commit is contained in:
@@ -45,7 +45,6 @@ abstract class IterableNotToContainEntriesExpectationsSpec(
|
||||
) = notToContainNullableEntries(this, a, aX)
|
||||
|
||||
val notToContainDescr = DescriptionIterableAssertion.CONTAINS_NOT.getDefault()
|
||||
val hasElement = DescriptionIterableAssertion.HAS_ELEMENT.getDefault()
|
||||
|
||||
nonNullableCases(
|
||||
describePrefix,
|
||||
@@ -67,13 +66,10 @@ abstract class IterableNotToContainEntriesExpectationsSpec(
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
toContainRegex(
|
||||
"\\Q$rootBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$indentRootBulletPoint\\Q$listBulletPoint\\E$anElementWhich: $separator" +
|
||||
"$afterExplanatory$toBeDescr: 4.0.*$separator" +
|
||||
"$featureSuccess$numberOfOccurrences: 0$separator" +
|
||||
"$isAfterSuccess: 0.*$separator" +
|
||||
"$featureFailing$hasElement: false$separator" +
|
||||
"$isAfterFailing: true"
|
||||
"$hasANextElement$separator" +
|
||||
"$indentRootBulletPoint\\Q$explanatoryBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$indentRootBulletPoint$indentListBulletPoint\\Q$listBulletPoint\\E$anElementWhich: $separator" +
|
||||
"$indentListBulletPoint$afterExplanatory$toBeDescr: 4.0.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -104,10 +100,10 @@ abstract class IterableNotToContainEntriesExpectationsSpec(
|
||||
"\\Q$rootBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$indentRootBulletPoint\\Q$listBulletPoint\\E$anElementWhich: $separator" +
|
||||
"$afterExplanatory$toBeLessThanDescr: 4.0.*$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 3$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(0, "1.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(1, "2.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(5, "3.0")}.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -121,16 +117,14 @@ abstract class IterableNotToContainEntriesExpectationsSpec(
|
||||
"\\Q$rootBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$indentRootBulletPoint\\Q$listBulletPoint\\E$anElementWhich: $separator" +
|
||||
"$afterExplanatory$toBeDescr: 1.0.*$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 1$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true$separator" +
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(0, "1.0")}.*$separator" +
|
||||
"$indentRootBulletPoint\\Q$listBulletPoint\\E$anElementWhich: $separator" +
|
||||
"$afterExplanatory$toBeDescr: 4.0.*$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 3$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(2, "4.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(3, "4.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(8, "4.0")}.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -167,10 +161,9 @@ abstract class IterableNotToContainEntriesExpectationsSpec(
|
||||
"\\Q$rootBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$indentRootBulletPoint\\Q$listBulletPoint\\E$anElementWhich: $separator" +
|
||||
"$afterExplanatory$isDescr: null$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 2$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(1, "null")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(5, "null")}.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -185,10 +178,9 @@ abstract class IterableNotToContainEntriesExpectationsSpec(
|
||||
"\\Q$rootBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$indentRootBulletPoint\\Q$listBulletPoint\\E$anElementWhich: $separator" +
|
||||
"$afterExplanatory$isDescr: null$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 2$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${index(1)}: null.*$separator" +
|
||||
"$afterMismatchedWarning${index(5)}: null.*"
|
||||
)
|
||||
this.notToContain("$notToContainDescr: 1.1")
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import ch.tutteli.atrium.api.fluent.en_GB.*
|
||||
import ch.tutteli.atrium.api.verbs.internal.expect
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.translations.DescriptionIterableAssertion
|
||||
|
||||
abstract class IterableNotToContainValuesExpectationsSpec(
|
||||
notToContainValues: Fun2<Iterable<Double>, Double, Array<out Double>>,
|
||||
@@ -24,9 +23,6 @@ abstract class IterableNotToContainValuesExpectationsSpec(
|
||||
fun Expect<Iterable<Double?>>.notToContainNullableFun(a: Double?, vararg aX: Double?) =
|
||||
notToContainNullableValues(this, a, aX)
|
||||
|
||||
val notToContainDescr = DescriptionIterableAssertion.CONTAINS_NOT.getDefault()
|
||||
val hasElement = DescriptionIterableAssertion.HAS_ELEMENT.getDefault()
|
||||
|
||||
val anElementWhichIsWithIndent = "$indentRootBulletPoint$listBulletPoint$anElementWhichIs"
|
||||
|
||||
nonNullableCases(
|
||||
@@ -46,12 +42,9 @@ abstract class IterableNotToContainValuesExpectationsSpec(
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
toContainRegex(
|
||||
"\\Q$rootBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$anElementWhichIsWithIndent: 4.0.*$separator" +
|
||||
"$featureSuccess$numberOfOccurrences: 0$separator" +
|
||||
"$isAfterSuccess: 0.*$separator" +
|
||||
"$featureFailing$hasElement: false$separator" +
|
||||
"$isAfterFailing: true"
|
||||
"$hasANextElement$separator" +
|
||||
"$indentRootBulletPoint\\Q$explanatoryBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$indentListBulletPoint$anElementWhichIsWithIndent: 4.0.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -81,10 +74,10 @@ abstract class IterableNotToContainValuesExpectationsSpec(
|
||||
toContainRegex(
|
||||
"\\Q$rootBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$anElementWhichIsWithIndent: 4.0.*$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 3$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(2, "4.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(3, "4.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(8, "4.0")}.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -97,15 +90,13 @@ abstract class IterableNotToContainValuesExpectationsSpec(
|
||||
toContainRegex(
|
||||
"\\Q$rootBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$anElementWhichIsWithIndent: 1.0.*$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 1$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true$separator" +
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(0, "1.0")}.*$separator" +
|
||||
"$anElementWhichIsWithIndent: 4.0.*$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 3$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(2, "4.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(3, "4.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(8, "4.0")}.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -118,15 +109,13 @@ abstract class IterableNotToContainValuesExpectationsSpec(
|
||||
toContainRegex(
|
||||
"\\Q$rootBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$anElementWhichIsWithIndent: 4.0.*$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 3$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true$separator" +
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(2, "4.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(3, "4.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(8, "4.0")}.*$separator" +
|
||||
"$anElementWhichIsWithIndent: 1.0.*$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 1$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(0, "1.0")}.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -152,10 +141,9 @@ abstract class IterableNotToContainValuesExpectationsSpec(
|
||||
toContainRegex(
|
||||
"\\Q$rootBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$anElementWhichIsWithIndent: null$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 2$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(1, "null")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(5, "null")}.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -169,10 +157,9 @@ abstract class IterableNotToContainValuesExpectationsSpec(
|
||||
toContainRegex(
|
||||
"\\Q$rootBulletPoint\\E$notToContainDescr: $separator" +
|
||||
"$anElementWhichIsWithIndent: null$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 2$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(1, "null")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(5, "null")}.*"
|
||||
)
|
||||
notToContain("$notToContainDescr: 1.1")
|
||||
}
|
||||
|
||||
@@ -23,14 +23,18 @@ abstract class IterableToContainEntriesSpecBase(
|
||||
val anElementWhich = DescriptionIterableAssertion.AN_ELEMENT_WHICH.getDefault()
|
||||
val toBeLessThanDescr = DescriptionComparableAssertion.IS_LESS_THAN.getDefault()
|
||||
val toBeGreaterThanDescr = DescriptionComparableAssertion.IS_GREATER_THAN.getDefault()
|
||||
fun <T> mismatchedIndex(index: Int, value: T) : String {
|
||||
val indexDescr = String.format(DescriptionIterableAssertion.INDEX.getDefault(), index)
|
||||
return "$indexDescr: ${value.toString()}"
|
||||
}
|
||||
|
||||
fun index(index: Int) = String.format(DescriptionIterableAssertion.INDEX.getDefault(), index)
|
||||
|
||||
//@formatter:off
|
||||
val featureSuccess = "$indentRootBulletPoint$indentListBulletPoint\\Q$successfulBulletPoint$featureArrow\\E"
|
||||
val featureFailing = "$indentRootBulletPoint$indentListBulletPoint\\Q$failingBulletPoint$featureArrow\\E"
|
||||
val isAfterFailing = "$indentRootBulletPoint$indentListBulletPoint$indentFailingBulletPoint$indentFeatureArrow\\Q$featureBulletPoint\\E$isDescr"
|
||||
val isAfterSuccess = "$indentRootBulletPoint$indentListBulletPoint$indentSuccessfulBulletPoint$indentFeatureArrow\\Q$featureBulletPoint\\E$isDescr"
|
||||
val afterExplanatory = "$indentRootBulletPoint$indentListBulletPoint$indentSuccessfulBulletPoint\\Q$explanatoryBulletPoint\\E"
|
||||
val afterExplanatoryIndent = "$indentRootBulletPoint$indentListBulletPoint$indentSuccessfulBulletPoint"
|
||||
val afterMismatchedWarning = "$afterExplanatoryIndent$indentWarningBulletPoint\\Q$listBulletPoint\\E"
|
||||
val hasANextElement = "\\Q$rootBulletPoint\\E$hasDescriptionBasic: $nextElement"
|
||||
//@formatter:on
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import ch.tutteli.atrium.api.fluent.en_GB.toContain
|
||||
import ch.tutteli.atrium.core.polyfills.format
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.translations.DescriptionBasic
|
||||
import ch.tutteli.atrium.translations.DescriptionCollectionAssertion
|
||||
import ch.tutteli.atrium.translations.DescriptionIterableAssertion
|
||||
import org.spekframework.spek2.Spek
|
||||
@@ -43,6 +44,9 @@ abstract class IterableToContainSpecBase(spec: Root.() -> Unit) : Spek(spec) {
|
||||
val mismatchesAdditionalElements = DescriptionIterableAssertion.WARNING_MISMATCHES_ADDITIONAL_ELEMENTS.getDefault()
|
||||
val sizeExceeded = DescriptionIterableAssertion.SIZE_EXCEEDED.getDefault()
|
||||
val anElementWhichIs = DescriptionIterableAssertion.AN_ELEMENT_WHICH_EQUALS.getDefault()
|
||||
val hasDescriptionBasic = DescriptionBasic.HAS.getDefault()
|
||||
val nextElement = DescriptionIterableAssertion.NEXT_ELEMENT.getDefault()
|
||||
val notToContainDescr = DescriptionIterableAssertion.CONTAINS_NOT.getDefault()
|
||||
|
||||
val sizeDescr = DescriptionCollectionAssertion.SIZE.getDefault()
|
||||
val atLeastDescr = DescriptionIterableAssertion.AT_LEAST.getDefault()
|
||||
|
||||
@@ -29,7 +29,6 @@ abstract class IterableToHaveElementsAndNoneExpectationsSpec(
|
||||
) {})
|
||||
|
||||
val containsNotDescr = DescriptionIterableAssertion.CONTAINS_NOT.getDefault()
|
||||
val hasElement = DescriptionIterableAssertion.HAS_ELEMENT.getDefault()
|
||||
|
||||
nonNullableCases(
|
||||
describePrefix,
|
||||
@@ -42,7 +41,14 @@ abstract class IterableToHaveElementsAndNoneExpectationsSpec(
|
||||
expect {
|
||||
expect(fluentEmpty()).toHaveElementsAndNoneFun { toBeLessThan(1.0) }
|
||||
}.toThrow<AssertionError> {
|
||||
messageToContain("$featureArrow$hasElement: false")
|
||||
message {
|
||||
toContainRegex(
|
||||
"$hasANextElement$separator" +
|
||||
"$indentRootBulletPoint\\Q$explanatoryBulletPoint\\E$containsNotDescr: $separator" +
|
||||
"$indentRootBulletPoint$indentListBulletPoint\\Q$listBulletPoint\\E$anElementWhich: $separator" +
|
||||
"$indentListBulletPoint$afterExplanatory$toBeLessThanDescr: 1.0.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,10 +72,10 @@ abstract class IterableToHaveElementsAndNoneExpectationsSpec(
|
||||
"\\Q$rootBulletPoint\\E$containsNotDescr: $separator" +
|
||||
"$indentRootBulletPoint\\Q$listBulletPoint\\E$anElementWhich: $separator" +
|
||||
"$afterExplanatory$toBeDescr: 4.0.*$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 3$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(2, "4.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(3, "4.0")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(8, "4.0")}.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -96,10 +102,9 @@ abstract class IterableToHaveElementsAndNoneExpectationsSpec(
|
||||
"\\Q$rootBulletPoint\\E$containsNotDescr: $separator" +
|
||||
"$indentRootBulletPoint\\Q$listBulletPoint\\E$anElementWhich: $separator" +
|
||||
"$afterExplanatory$isDescr: null$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 2$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(1, "null")}.*$separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(5, "null")}.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -114,10 +119,8 @@ abstract class IterableToHaveElementsAndNoneExpectationsSpec(
|
||||
"\\Q$rootBulletPoint\\E$containsNotDescr: $separator" +
|
||||
"$indentRootBulletPoint\\Q$listBulletPoint\\E$anElementWhich: $separator" +
|
||||
"$afterExplanatory$toBeDescr: 1.0.*$separator" +
|
||||
"$featureFailing$numberOfOccurrences: 1$separator" +
|
||||
"$isAfterFailing: 0.*$separator" +
|
||||
"$featureSuccess$hasElement: true$separator" +
|
||||
"$isAfterSuccess: true"
|
||||
"$afterExplanatoryIndent\\Q$warningBulletPoint$mismatches:\\E $separator" +
|
||||
"$afterMismatchedWarning${mismatchedIndex(0, "1.0")}.*"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user