notToContain

Expects that the subject of this expectation (a CharSequence) does not contain expected's toString representation and neither one of the otherExpected's toString representation (if given).

It is a shortcut for notToContain.values(expected, *otherExpected).

Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed. This function expects CharSequenceOrNumberOrChar (which is a typealias for Any) for your convenience, so that you can mix String and Int for instance.

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

expect("ABC").notToContain("X")

expect("ABC").notToContain("X", 'Y', 1)

fails {
    expect("ABC").notToContain("B")
}

fails {
    expect("ABC").notToContain("B", "X")
}

fun <E, T : Iterable<E>> Expect<T>.notToContain(expected: E, vararg otherExpected: E): Expect<T>(source)

Expects that the subject of this expectation (an Iterable) has at least one element and that it does not contain the expected value and neither one of the otherExpected values (if given).

It is a shortcut for notToContain.values(expected, *otherExpected)

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

expect(listOf("A", "B", "C")).notToContain("D", "E")

fails {
    expect(listOf("A", "B", "C")).notToContain("A", "D")
}

Starts a sophisticated noToContain assertion building process based on this Expect and already chooses a NotCheckerStep.

Return

The newly created builder.

Since

0.17.0

Samples

expect("ABC").notToContain.value("X")

fails {
    expect("ABC").notToContain.value("B")
}

Starts a sophisticated toContain assertion building process based on this Expect and already chooses a NotCheckerStep.

Return

The newly created builder.

Since

0.17.0

Samples

expect(listOf("A", "B"))
    .notToContain
    .elementsOf(setOf("C", "D"))

fails {
    expect(listOf(1, 8, 5))
        .notToContain
        .entry { // expectation-group about the entry
            toBeGreaterThan(6)
        }
}