diff --git a/assertk/src/commonMain/kotlin/assertk/assertions/throwable.kt b/assertk/src/commonMain/kotlin/assertk/assertions/throwable.kt index a856d3f4..5aa30b9a 100644 --- a/assertk/src/commonMain/kotlin/assertk/assertions/throwable.kt +++ b/assertk/src/commonMain/kotlin/assertk/assertions/throwable.kt @@ -6,30 +6,30 @@ import assertk.all /** * Returns an assert on the throwable's message. */ -fun Assert.message() = having("message", Throwable::message) +fun Assert.havingMessage() = having("message", Throwable::message) /** * Returns an assert on the throwable's cause. */ -fun Assert.cause() = having("cause", Throwable::cause) +fun Assert.havingCause() = having("cause", Throwable::cause) /** * Returns an assert on the throwable's root cause. */ -fun Assert.rootCause() = having("rootCause", Throwable::rootCause) +fun Assert.havingRootCause() = having("rootCause", Throwable::rootCause) /** * Asserts the throwable has the expected message. */ fun Assert.hasMessage(message: String?) { - message().isEqualTo(message) + havingMessage().isEqualTo(message) } /** * Asserts the throwable contains the expected text */ fun Assert.messageContains(text: String) { - message().isNotNull().contains(text) + havingMessage().isNotNull().contains(text) } /** @@ -37,7 +37,7 @@ fun Assert.messageContains(text: String) { * @see [hasNoCause] */ fun Assert.hasCause(cause: Throwable) { - cause().isNotNull().all { + havingCause().isNotNull().all { kClass().isEqualTo(cause::class) hasMessage(cause.message) } @@ -48,14 +48,14 @@ fun Assert.hasCause(cause: Throwable) { * @see [hasCause] */ fun Assert.hasNoCause() { - cause().isNull() + havingCause().isNull() } /** * Asserts the throwable is similar to the expected root cause, checking the type and message. */ fun Assert.hasRootCause(cause: Throwable) { - rootCause().all { + havingRootCause().all { kClass().isEqualTo(cause::class) hasMessage(cause.message) } diff --git a/assertk/src/commonTest/kotlin/test/assertk/AssertFailureTest.kt b/assertk/src/commonTest/kotlin/test/assertk/AssertFailureTest.kt index 48882746..b5bf3c88 100644 --- a/assertk/src/commonTest/kotlin/test/assertk/AssertFailureTest.kt +++ b/assertk/src/commonTest/kotlin/test/assertk/AssertFailureTest.kt @@ -3,7 +3,7 @@ package test.assertk import assertk.assertFailure import assertk.assertions.isEqualTo import assertk.assertions.isInstanceOf -import assertk.assertions.message +import assertk.assertions.havingMessage import com.willowtreeapps.opentest4k.AssertionFailedError import test.assertk.assertions.valueOrFail import kotlin.coroutines.resume @@ -28,7 +28,7 @@ class AssertFailureTest { fun failure_originating_subject_not_wrapped_in_result() { val t = assertFailsWith { assertFailure { throw RuntimeException("foo") } - .message() + .havingMessage() .isEqualTo("bar") } assertTrue("RuntimeException" in t.message!!) diff --git a/assertk/src/commonTest/kotlin/test/assertk/assertions/ThrowableTest.kt b/assertk/src/commonTest/kotlin/test/assertk/assertions/ThrowableTest.kt index 008cc9bd..7864e348 100644 --- a/assertk/src/commonTest/kotlin/test/assertk/assertions/ThrowableTest.kt +++ b/assertk/src/commonTest/kotlin/test/assertk/assertions/ThrowableTest.kt @@ -14,17 +14,17 @@ class ThrowableTest { @Test fun extracts_message() { - assertEquals(subject.message, assertThat(subject).message().valueOrFail) + assertEquals(subject.message, assertThat(subject).havingMessage().valueOrFail) } @Test fun extracts_cause() { - assertEquals(cause, assertThat(subject).cause().valueOrFail) + assertEquals(cause, assertThat(subject).havingCause().valueOrFail) } @Test fun extracts_root_cause() { - assertEquals(rootCause, assertThat(subject).rootCause().valueOrFail) + assertEquals(rootCause, assertThat(subject).havingRootCause().valueOrFail) } //region hasMessage diff --git a/assertk/src/commonTest/kotlin/test/assertk/assertions/support/SupportTest.kt b/assertk/src/commonTest/kotlin/test/assertk/assertions/support/SupportTest.kt index 4dff6db2..db619305 100644 --- a/assertk/src/commonTest/kotlin/test/assertk/assertions/support/SupportTest.kt +++ b/assertk/src/commonTest/kotlin/test/assertk/assertions/support/SupportTest.kt @@ -1,11 +1,9 @@ package test.assertk.assertions.support import assertk.assertThat -import assertk.assertions.hasMessage -import assertk.assertions.isEqualTo import assertk.assertions.isFailure import assertk.assertions.isSuccess -import assertk.assertions.message +import assertk.assertions.havingMessage import assertk.assertions.support.expected import assertk.assertions.support.fail import assertk.assertions.support.show @@ -236,7 +234,7 @@ class SupportTest { @Test fun expected_originating_throwable_included_as_cause() { val subject = RuntimeException() - val assert = assertThat(subject).message() + val assert = assertThat(subject).havingMessage() val error = assertFailsWith { assert.expected("message") } @@ -246,7 +244,7 @@ class SupportTest { @Test fun expected_originating_failure_result_included_as_cause() { val subject = RuntimeException() - val assert = assertThat(Result.failure(subject)).isFailure().message() + val assert = assertThat(Result.failure(subject)).isFailure().havingMessage() val error = assertFailsWith { assert.expected("message") }