If

inline fun If(predicate: () -> Boolean): TestConfig(source)

Marks this test or an entire suite as disabled if predicate returns true.

If predicate returns false, does nothing.

Example

Mark a suite as disabled:

suite("Suite name", Ignored.If { true }) {
// …
}

Mark a test as disabled:

test("Some kind of test", Ignored.If { true }) {
// …
}

Use-case

Conceptually, marking a test as ignored:

test("Some kind of test", Ignored.If { someCondition }) {
// …
}

is similar to not declaring the test at all:

if (!someCondition) {
test("Some kind of test") {
// …
}
}

However, some test runners (e.g., TestBalloon) refuse to execute suites that are declared without any tests. Declaring tests as conditionally ignored avoids this issue.

See also

Always ignore a test or suite.

Opposite.