-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Issue-1625): write example tests for aborted scenarios
- Loading branch information
1 parent
8e1da95
commit 57be682
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...src/test/java/com/tngtech/jgiven/examples/assumptions/AssumptionFailureTestScenarios.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.tngtech.jgiven.examples.assumptions; | ||
|
||
import com.tngtech.jgiven.annotation.ScenarioStage; | ||
import com.tngtech.jgiven.junit.JGivenClassRule; | ||
import com.tngtech.jgiven.junit.JGivenMethodRule; | ||
import org.junit.Assume; | ||
import org.junit.ClassRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
@SuppressWarnings("NewClassNamingConvention") | ||
public class AssumptionFailureTestScenarios { | ||
|
||
@ClassRule | ||
public static final JGivenClassRule writerRule = new JGivenClassRule(); | ||
|
||
@Rule | ||
public final JGivenMethodRule scenarioRule = new JGivenMethodRule(); | ||
|
||
@ScenarioStage | ||
AssumptionFailureTestStage givenTestStage; | ||
|
||
@SuppressWarnings("DataFlowIssue") | ||
@Test | ||
public void test_with_failing_assumption() { | ||
Assume.assumeFalse(true); | ||
} | ||
|
||
@Test | ||
public void test_with_failing_assumption_in_stage() { | ||
givenTestStage.given().a_failed_junit_assumption().and() | ||
.nothing(); | ||
|
||
} | ||
|
||
@Test | ||
public void test_with_failing_assumption_in_second_stage(){ | ||
givenTestStage.given().nothing().and() | ||
.a_failed_junit_assumption(); | ||
} | ||
|
||
@Test | ||
public void test_with_failing_assumption_in_a_nested_stage(){ | ||
givenTestStage.given().nothing().a_failed_nested_step().and().nothing(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...les/src/test/java/com/tngtech/jgiven/examples/assumptions/AssumptionFailureTestStage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.tngtech.jgiven.examples.assumptions; | ||
|
||
import com.tngtech.jgiven.Stage; | ||
import com.tngtech.jgiven.annotation.NestedSteps; | ||
import org.junit.Assume; | ||
|
||
public class AssumptionFailureTestStage extends Stage<AssumptionFailureTestStage> { | ||
|
||
public AssumptionFailureTestStage nothing() { | ||
return self(); | ||
} | ||
|
||
@SuppressWarnings("DataFlowIssue") //fail on purpose | ||
public AssumptionFailureTestStage a_failed_junit_assumption() { | ||
Assume.assumeFalse(true); | ||
return self(); | ||
} | ||
|
||
@NestedSteps | ||
public AssumptionFailureTestStage a_failed_nested_step() { | ||
self().a_failed_junit_assumption(); | ||
return self(); | ||
} | ||
} |