mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
Merge pull request #740 from robstoll/info-bullet-unexpected-exception
Info bullet unexpected exception
This commit is contained in:
60
README.md
60
README.md
@@ -385,13 +385,13 @@ expect {
|
||||
expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$4$1 <1234789>)
|
||||
◆ ▶ thrown exception when called: java.lang.IllegalArgumentException
|
||||
◾ is instance of type: IllegalStateException (java.lang.IllegalStateException)
|
||||
» Properties of the unexpected IllegalArgumentException
|
||||
» message: "name is empty" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.ReadmeSpec$1$4$1.invoke(ReadmeSpec.kt:76)
|
||||
⚬ readme.examples.ReadmeSpec$1$4$1.invoke(ReadmeSpec.kt:51)
|
||||
⚬ readme.examples.ReadmeSpec$1$4.invoke(ReadmeSpec.kt:691)
|
||||
⚬ readme.examples.ReadmeSpec$1$4.invoke(ReadmeSpec.kt:51)
|
||||
ℹ Properties of the unexpected IllegalArgumentException
|
||||
» message: "name is empty" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.ReadmeSpec$1$4$1.invoke(ReadmeSpec.kt:76)
|
||||
⚬ readme.examples.ReadmeSpec$1$4$1.invoke(ReadmeSpec.kt:51)
|
||||
⚬ readme.examples.ReadmeSpec$1$4.invoke(ReadmeSpec.kt:691)
|
||||
⚬ readme.examples.ReadmeSpec$1$4.invoke(ReadmeSpec.kt:51)
|
||||
```
|
||||
</ex-toThrow1>
|
||||
|
||||
@@ -465,17 +465,17 @@ expect {
|
||||
```text
|
||||
expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$7$1 <1234789>)
|
||||
◆ ▶ invoke(): ❗❗ threw java.lang.IllegalArgumentException
|
||||
» Properties of the unexpected IllegalArgumentException
|
||||
» message: "name is empty" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.ReadmeSpec$1$7$1.invoke(ReadmeSpec.kt:97)
|
||||
⚬ readme.examples.ReadmeSpec$1$7$1.invoke(ReadmeSpec.kt:51)
|
||||
⚬ readme.examples.ReadmeSpec$1$7.invoke(ReadmeSpec.kt:98)
|
||||
⚬ readme.examples.ReadmeSpec$1$7.invoke(ReadmeSpec.kt:51)
|
||||
» cause: java.lang.RuntimeException
|
||||
» message: "a cause" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.ReadmeSpec$1$7$1.invoke(ReadmeSpec.kt:97)
|
||||
ℹ Properties of the unexpected IllegalArgumentException
|
||||
» message: "name is empty" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.ReadmeSpec$1$7$1.invoke(ReadmeSpec.kt:97)
|
||||
⚬ readme.examples.ReadmeSpec$1$7$1.invoke(ReadmeSpec.kt:51)
|
||||
⚬ readme.examples.ReadmeSpec$1$7.invoke(ReadmeSpec.kt:98)
|
||||
⚬ readme.examples.ReadmeSpec$1$7.invoke(ReadmeSpec.kt:51)
|
||||
» cause: java.lang.RuntimeException
|
||||
» message: "a cause" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.ReadmeSpec$1$7$1.invoke(ReadmeSpec.kt:97)
|
||||
```
|
||||
</ex-notToThrow>
|
||||
|
||||
@@ -1945,17 +1945,17 @@ expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec2$
|
||||
⚬ value: "no no no" <1234789>
|
||||
⚬ ▶ number of matches:
|
||||
◾ is at least: 1
|
||||
» Properties of the unexpected IllegalArgumentException
|
||||
» message: "no no no..." <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.ReadmeSpec2$1$42$1.invoke(ReadmeSpec.kt:472)
|
||||
⚬ readme.examples.ReadmeSpec2$1$42$1.invoke(ReadmeSpec.kt:227)
|
||||
⚬ readme.examples.ReadmeSpec2$1$42.invoke(ReadmeSpec.kt:691)
|
||||
⚬ readme.examples.ReadmeSpec2$1$42.invoke(ReadmeSpec.kt:227)
|
||||
» cause: java.lang.UnsupportedOperationException
|
||||
» message: "not supported" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.ReadmeSpec2$1$42$1.invoke(ReadmeSpec.kt:470)
|
||||
ℹ Properties of the unexpected IllegalArgumentException
|
||||
» message: "no no no..." <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.ReadmeSpec2$1$42$1.invoke(ReadmeSpec.kt:472)
|
||||
⚬ readme.examples.ReadmeSpec2$1$42$1.invoke(ReadmeSpec.kt:227)
|
||||
⚬ readme.examples.ReadmeSpec2$1$42.invoke(ReadmeSpec.kt:691)
|
||||
⚬ readme.examples.ReadmeSpec2$1$42.invoke(ReadmeSpec.kt:227)
|
||||
» cause: java.lang.UnsupportedOperationException
|
||||
» message: "not supported" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.ReadmeSpec2$1$42$1.invoke(ReadmeSpec.kt:470)
|
||||
```
|
||||
</ex-add-info-3>
|
||||
|
||||
@@ -1981,7 +1981,7 @@ expect(BigDecimal.TEN).isEqualIncludingScale(BigDecimal("10.0"))
|
||||
```text
|
||||
expected that subject: 10 (java.math.BigDecimal <1234789>)
|
||||
◆ is equal (including scale): 10.0 (java.math.BigDecimal <1234789>)
|
||||
» notice, if you used isNumericallyEqualTo then the assertion would have hold.
|
||||
ℹ notice, if you used isNumericallyEqualTo then the assertion would have hold.
|
||||
```
|
||||
</ex-pitfall-1>
|
||||
|
||||
|
||||
@@ -27,4 +27,4 @@ object WarningAssertionGroupType : ExplanatoryAssertionGroupType
|
||||
* The [AssertionGroupType] for [AssertionGroup]s whose [assertions][AssertionGroup.assertions] are used to document
|
||||
* the reason for one or multiple assertions.
|
||||
*/
|
||||
object InformationAssertionGroupType : ExplanatoryAssertionGroupType
|
||||
data class InformationAssertionGroupType(val withIndent: Boolean) : ExplanatoryAssertionGroupType
|
||||
|
||||
@@ -30,7 +30,7 @@ interface ExplanatoryGroup {
|
||||
/**
|
||||
* Builder to create an [AssertionGroup] with an [InformationAssertionGroupType].
|
||||
*/
|
||||
override val withInformationType: AssertionsOption<InformationAssertionGroupType, FinalStep>
|
||||
override fun withInformationType(withIndent: Boolean): AssertionsOption<InformationAssertionGroupType, FinalStep>
|
||||
|
||||
/**
|
||||
* Builder to create an [AssertionGroup] with a custom [ExplanatoryAssertionGroupType].
|
||||
@@ -174,7 +174,7 @@ interface ExplanatoryAssertionGroupTypeOption {
|
||||
/**
|
||||
* Builder to create an [AssertionGroup] with a [InformationAssertionGroupType].
|
||||
*/
|
||||
val withInformationType: AssertionsOption<InformationAssertionGroupType, ExplanatoryAssertionGroupFinalStep>
|
||||
fun withInformationType(withIndent: Boolean): AssertionsOption<InformationAssertionGroupType, ExplanatoryAssertionGroupFinalStep>
|
||||
|
||||
/**
|
||||
* Builder to create an [AssertionGroup] with a custom [ExplanatoryAssertionGroupType].
|
||||
|
||||
@@ -13,8 +13,8 @@ internal object GroupTypeOptionImpl : ExplanatoryGroup.GroupTypeOption {
|
||||
override val withWarningType: AssertionsOption<WarningAssertionGroupType, ExplanatoryGroup.FinalStep> =
|
||||
createAssertionsOption(WarningAssertionGroupType)
|
||||
|
||||
override val withInformationType: AssertionsOption<InformationAssertionGroupType, ExplanatoryGroup.FinalStep> =
|
||||
createAssertionsOption(InformationAssertionGroupType)
|
||||
override fun withInformationType(withIndent: Boolean): AssertionsOption<InformationAssertionGroupType, ExplanatoryGroup.FinalStep> =
|
||||
createAssertionsOption(InformationAssertionGroupType(withIndent))
|
||||
|
||||
override fun <T : ExplanatoryAssertionGroupType> withType(
|
||||
groupType: T
|
||||
|
||||
@@ -45,15 +45,22 @@ class TextExplanatoryAssertionGroupFormatter(
|
||||
assertionGroup: AssertionGroup,
|
||||
parameterObject: AssertionFormatterParameterObject
|
||||
): AssertionFormatterParameterObject {
|
||||
// we don't indent in case of an InformationAssertionGroupType
|
||||
return if (assertionGroup.type == InformationAssertionGroupType) {
|
||||
parameterObject.createForExplanatoryFilterAssertionGroup(informationBulletPoint)
|
||||
} else {
|
||||
val bulletPoint = when (assertionGroup.type) {
|
||||
WarningAssertionGroupType -> warningBulletPoint
|
||||
else -> explanatoryBulletPoint
|
||||
}
|
||||
fun withIndent(bulletPoint: String) =
|
||||
parameterObject.createForExplanatoryFilterAssertionGroup().createChildWithNewPrefix(bulletPoint)
|
||||
|
||||
fun withOrWithoutIndent(bulletPoint: String, withIndent: Boolean) =
|
||||
if (withIndent) withIndent(bulletPoint)
|
||||
else parameterObject.createForExplanatoryFilterAssertionGroup(bulletPoint)
|
||||
|
||||
//TODO 1.0.0 move val inside when
|
||||
val assertionGroupType = assertionGroup.type
|
||||
return when (assertionGroupType) {
|
||||
is InformationAssertionGroupType -> withOrWithoutIndent(
|
||||
informationBulletPoint,
|
||||
assertionGroupType.withIndent
|
||||
)
|
||||
WarningAssertionGroupType -> withIndent(warningBulletPoint)
|
||||
else -> withIndent(explanatoryBulletPoint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,14 @@ class TextExplanatoryAssertionGroupFormatterSpec : Spek({
|
||||
factory(), "[Atrium's TextWarning...Spec] "
|
||||
)
|
||||
|
||||
object AtriumsTextInformationWithIndentAssertionFormatterSpec :
|
||||
ch.tutteli.atrium.specs.reporting.TextInformationAssertionGroupFormatterSpec(
|
||||
factory(), withIndent = true, describePrefix = "[Atrium's TextInformation...Spec] "
|
||||
)
|
||||
|
||||
object AtriumsTextInformationAssertionFormatterSpec :
|
||||
ch.tutteli.atrium.specs.reporting.TextInformationAssertionGroupFormatterSpec(
|
||||
factory(), "[Atrium's TextInformation...Spec] "
|
||||
factory(), withIndent = false, describePrefix = "[Atrium's TextInformation...Spec] "
|
||||
)
|
||||
|
||||
object AtriumsEmptyNameAndSubjectAssertionGroupFormatterSpec :
|
||||
|
||||
@@ -60,8 +60,7 @@ class ThrowableThrownFailureHandler<T : Throwable?, R> : SubjectChanger.FailureH
|
||||
explanation: Assertion = createExplanation(throwable)
|
||||
): AssertionGroup =
|
||||
assertionBuilder.explanatoryGroup
|
||||
// TODO change to InformationType with 0.15.0
|
||||
.withDefaultType
|
||||
.withInformationType(withIndent = false)
|
||||
.withAssertions(
|
||||
explanation,
|
||||
createHints(throwable, secondStackFrameOfParent = null)
|
||||
|
||||
@@ -103,7 +103,7 @@ class DefaultAnyAssertions : AnyAssertions {
|
||||
return assertionBuilder.invisibleGroup.withAssertions(
|
||||
assertion,
|
||||
assertionBuilder.explanatoryGroup
|
||||
.withInformationType
|
||||
.withInformationType(withIndent = false)
|
||||
.withAssertion(assertionBuilder.createDescriptive(BECAUSE, Text(reason), falseProvider))
|
||||
.build()
|
||||
).build()
|
||||
|
||||
@@ -38,7 +38,7 @@ class DefaultBigDecimalAssertions : BigDecimalAssertions {
|
||||
.withTest(container) { it == expected }
|
||||
.withFailureHint {
|
||||
assertionBuilder.explanatoryGroup
|
||||
.withDefaultType
|
||||
.withInformationType(withIndent = true)
|
||||
.withExplanatoryAssertion(
|
||||
FAILURE_IS_EQUAL_INCLUDING_SCALE_BUT_NUMERICALLY_EQUAL,
|
||||
nameOfIsNumericallyEqualTo
|
||||
|
||||
@@ -144,9 +144,17 @@ abstract class AssertionFormatterControllerSpec(
|
||||
warning
|
||||
),
|
||||
Triple(
|
||||
"$groupName with type ${InformationAssertionGroupType::class.simpleName}",
|
||||
factory(InformationAssertionGroupType, listOf(holdingAssertion)) to factory(
|
||||
InformationAssertionGroupType,
|
||||
"$groupName with type ${InformationAssertionGroupType::class.simpleName} and withIndent = true",
|
||||
factory(InformationAssertionGroupType(true), listOf(holdingAssertion)) to factory(
|
||||
InformationAssertionGroupType(true),
|
||||
listOf(failingAssertion)
|
||||
),
|
||||
information
|
||||
),
|
||||
Triple(
|
||||
"$groupName with type ${InformationAssertionGroupType::class.simpleName} and withIndent = false",
|
||||
factory(InformationAssertionGroupType(false), listOf(holdingAssertion)) to factory(
|
||||
InformationAssertionGroupType(false),
|
||||
listOf(failingAssertion)
|
||||
),
|
||||
information
|
||||
|
||||
@@ -9,12 +9,13 @@ import kotlin.reflect.KClass
|
||||
|
||||
abstract class TextInformationAssertionGroupFormatterSpec(
|
||||
testeeFactory: (Map<KClass<out BulletPointIdentifier>, String>, AssertionFormatterController) -> AssertionFormatter,
|
||||
withIndent: Boolean,
|
||||
describePrefix: String = "[Atrium] "
|
||||
) : TextExplanatoryBasedAssertionGroupFormatterSpec<InformationAssertionGroupType>(
|
||||
testeeFactory,
|
||||
InformationAssertionGroupType::class,
|
||||
InformationAssertionGroupType,
|
||||
{ assertionBuilder.explanatoryGroup.withInformationType.withAssertions(it).build() },
|
||||
InformationAssertionGroupType(withIndent),
|
||||
{ assertionBuilder.explanatoryGroup.withInformationType(withIndent).withAssertions(it).build() },
|
||||
describePrefix,
|
||||
withIndent = false
|
||||
withIndent
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user