If
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 }) {
// …
}Content copied to clipboard
Mark a test as disabled:
test("Some kind of test", Ignored.If { true }) {
// …
}Content copied to clipboard
Use-case
Conceptually, marking a test as ignored:
test("Some kind of test", Ignored.If { someCondition }) {
// …
}Content copied to clipboard
is similar to not declaring the test at all:
if (!someCondition) {
test("Some kind of test") {
// …
}
}Content copied to clipboard
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.