Added failWhenEverythingSkipped command line option

This commit is contained in:
Erik C. Thauvin 2023-08-15 23:06:39 -07:00
parent a84a6fe9e2
commit 1fb81b4156
2 changed files with 17 additions and 0 deletions

View file

@ -162,6 +162,14 @@ public class TestNgOperation extends AbstractProcessOperation<TestNgOperation> {
return this; return this;
} }
/**
* Should TestNG fail execution if all tests were skipped and nothing was run.
*/
public TestNgOperation failWhenEverythingSkipped(Boolean isFailAllSkipped) {
options.put("-failwheneverythingskipped", String.valueOf(isFailAllSkipped));
return this;
}
/** /**
* Whether TestNG should continue to execute the remaining tests in the suite or skip them if in a {@code @Before*} * Whether TestNG should continue to execute the remaining tests in the suite or skip them if in a {@code @Before*}
* method. * method.

View file

@ -105,6 +105,15 @@ class TestNgOperationTest {
.doesNotThrowAnyException(); .doesNotThrowAnyException();
} }
@Test
void testFailWheneverEverythingSkipped() {
var op = new TestNgOperation().failWhenEverythingSkipped(false);
assertThat(op.options.get("-failwheneverythingskipped")).isEqualTo("false");
op = new TestNgOperation().failWhenEverythingSkipped(true);
assertThat(op.options.get("-failwheneverythingskipped")).isEqualTo("true");
}
@Test @Test
void testFailurePolicy() { void testFailurePolicy() {
var op = new TestNgOperation().failurePolicy(TestNgOperation.FailurePolicy.CONTINUE); var op = new TestNgOperation().failurePolicy(TestNgOperation.FailurePolicy.CONTINUE);