• e

    Eric

    6 months ago
    is there a changelog for 0.34.1?
    e
    robfletcher
    4 replies
    Copy to Clipboard
  • dave08

    dave08

    5 months ago
    For this:
    expectThat(result) {
    			size.isEqualTo(4)
    			withElementAt(3) {
    ...
    I get this:
    Mapping 'element at index 3 %s' failed with: Index 3 out of bounds for length 3
    Mapping 'element at index 3 %s' failed with: Index 3 out of bounds for length 3
    	at app//strikt.internal.AssertionBuilder.with(AssertionBuilder.kt:138)
    	at app//strikt.assertions.IterableKt.withElementAt(Iterable.kt:70)
    Whereas I would have expected the
    size.isEqualTo(4)
    would give me the size of the array BEFORE crashing on an out of bounds error... or even better, for soft-expectations, maybe not crash at all? Just give an
    x
    just like any other failed assertion at the appropriate level?
    dave08
    1 replies
    Copy to Clipboard
  • e

    Eric

    5 months ago
    is there a way to only report failures in a large compound assertion to avoid the noise of everything that passed?
    e
    1 replies
    Copy to Clipboard
  • christophsturm

    christophsturm

    4 months ago
    I have a related idea: use something like pitest to test your test suite. and mark all assertions that never fail as suspicious. you would run a longer test task that mutates your code to check if it can get all your assertions to fail. and also display a report of the error message, then you can check that the error messages make sense.
    christophsturm
    1 replies
    Copy to Clipboard
  • r

    Roukanken

    4 months ago
    I wonder if there’s a way to prevent
    isA
    if the generic type of the function has its own generic type
    I don't think there is a way to prevent it compile time, but you can always just half-botch it by having the assert always fail when
    T::class.typeParameters
    is non-empty (eg, the reified class has some generic parameters on it's own)
    r
    christophsturm
    +2
    24 replies
    Copy to Clipboard
  • e

    Eric

    1 month ago
    withCaptured
    (mockk) breaks assertion chaining if the slot has not been captured. It throws
    Mapping 'captured value %s' failed with: lateinit property captured has not been initialized
    . Not sure if this is known or intentional. Would be nice if instead of throwing it would short circuit the block and fail.
    e
    robfletcher
    7 replies
    Copy to Clipboard
  • e

    Eric

    6 days ago
    comparables have isGreaterThan/isGreaterThanOrEqualTo/etc assertions but no check if equal using
    compareTo
    which is useful for things like
    BigDecimal
    maybe add this?
    fun <T : Comparable<T>> Assertion.Builder<T>.compareToEqual(expected: T) =
        assert("is equal using compareTo to %s", expected) {
            if (it.compareTo(expected) == 0) pass() else fail()
        }