diff --git a/README.md b/README.md index a442beb4f..1de5e1c10 100644 --- a/README.md +++ b/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) ``` @@ -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) ``` @@ -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) ``` @@ -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. ``` diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/ExplanatoryAssertionGroupType.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/ExplanatoryAssertionGroupType.kt index d9767ed57..0cc38a5a0 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/ExplanatoryAssertionGroupType.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/ExplanatoryAssertionGroupType.kt @@ -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 diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/explanatoryGroup.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/explanatoryGroup.kt index 742144b0f..a5bdcbebc 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/explanatoryGroup.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/explanatoryGroup.kt @@ -30,7 +30,7 @@ interface ExplanatoryGroup { /** * Builder to create an [AssertionGroup] with an [InformationAssertionGroupType]. */ - override val withInformationType: AssertionsOption + override fun withInformationType(withIndent: Boolean): AssertionsOption /** * 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 + fun withInformationType(withIndent: Boolean): AssertionsOption /** * Builder to create an [AssertionGroup] with a custom [ExplanatoryAssertionGroupType]. diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/impl/explanatoryGroup/defaultImpls.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/impl/explanatoryGroup/defaultImpls.kt index f23c1474f..45804d439 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/impl/explanatoryGroup/defaultImpls.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/impl/explanatoryGroup/defaultImpls.kt @@ -13,8 +13,8 @@ internal object GroupTypeOptionImpl : ExplanatoryGroup.GroupTypeOption { override val withWarningType: AssertionsOption = createAssertionsOption(WarningAssertionGroupType) - override val withInformationType: AssertionsOption = - createAssertionsOption(InformationAssertionGroupType) + override fun withInformationType(withIndent: Boolean): AssertionsOption = + createAssertionsOption(InformationAssertionGroupType(withIndent)) override fun withType( groupType: T diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatter.kt b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatter.kt index 2abc99039..7b385f44e 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatter.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatter.kt @@ -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) } } } diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt index cf01704f7..2fa3ca898 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt @@ -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 : diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/ThrowableThrownFailureHandler.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/ThrowableThrownFailureHandler.kt index 74c96f81c..416b22f8e 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/ThrowableThrownFailureHandler.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/ThrowableThrownFailureHandler.kt @@ -60,8 +60,7 @@ class ThrowableThrownFailureHandler : 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) diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultAnyAssertions.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultAnyAssertions.kt index 0fff5138b..4c7d78fad 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultAnyAssertions.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultAnyAssertions.kt @@ -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() diff --git a/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultBigDecimalAssertions.kt b/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultBigDecimalAssertions.kt index eb6312d77..348bd5d1e 100644 --- a/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultBigDecimalAssertions.kt +++ b/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultBigDecimalAssertions.kt @@ -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 diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterControllerSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterControllerSpec.kt index f70d5d397..47fc64ccb 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterControllerSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterControllerSpec.kt @@ -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 diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextInformationAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextInformationAssertionGroupFormatterSpec.kt index 755322df5..59662ef54 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextInformationAssertionGroupFormatterSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextInformationAssertionGroupFormatterSpec.kt @@ -9,12 +9,13 @@ import kotlin.reflect.KClass abstract class TextInformationAssertionGroupFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController) -> AssertionFormatter, + withIndent: Boolean, describePrefix: String = "[Atrium] " ) : TextExplanatoryBasedAssertionGroupFormatterSpec( testeeFactory, InformationAssertionGroupType::class, - InformationAssertionGroupType, - { assertionBuilder.explanatoryGroup.withInformationType.withAssertions(it).build() }, + InformationAssertionGroupType(withIndent), + { assertionBuilder.explanatoryGroup.withInformationType(withIndent).withAssertions(it).build() }, describePrefix, - withIndent = false + withIndent )