Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Throwable's message assertion #73

Open
4 tasks
LVMVRQUXL opened this issue Nov 26, 2022 · 0 comments
Open
4 tasks

Throwable's message assertion #73

LVMVRQUXL opened this issue Nov 26, 2022 · 0 comments
Labels
assert Related to Kotools Assert library. common Should work on all platforms. enhancement New feature or request.

Comments

@LVMVRQUXL
Copy link
Contributor

Description

The problem

For checking if an exception has a message, users have to do the following boilerplate code in each test:

import kotools.assert.assertNotNull
import kotools.assert.assertTrue

fun test() {
   assertFailsWith<Throwable> { /* ... */ }
        .message
        .assertNotNull()
        .isNotBlank()
        .assertTrue()
}

The solution

Introduce a new Throwable.assertHasNotBlankMessage function checking that this throwable has a not blank message.

import kotools.assert.assertFailsWith

/** Asserts that this exception has a not blank message. */
fun <A : Throwable> A.assertHasNotBlankMessage(): Unit = TODO()

fun test() {
   assertFailsWith<Throwable> { /* ... */ }
        .assertHasNotBlankMessage()
}

Checklist

  • Implement.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.
@LVMVRQUXL LVMVRQUXL added enhancement New feature or request. common Should work on all platforms. assert Related to Kotools Assert library. labels Nov 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
assert Related to Kotools Assert library. common Should work on all platforms. enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

1 participant