-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with @pending(executeSteps = true) that marked a scenario a…
…s failed instead of pending (fixes #402)
- Loading branch information
1 parent
4481185
commit 34dab3a
Showing
10 changed files
with
152 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
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
8 changes: 8 additions & 0 deletions
8
jgiven-core/src/main/java/com/tngtech/jgiven/impl/util/ThrowableUtil.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,8 @@ | ||
package com.tngtech.jgiven.impl.util; | ||
|
||
public class ThrowableUtil { | ||
public static boolean isAssumptionException(Throwable t) { | ||
return t.getClass().getName().equals( "org.junit.AssumptionViolatedException" ) | ||
|| t.getClass().getName().equals( "org.testng.SkipException"); | ||
} | ||
} |
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
74 changes: 74 additions & 0 deletions
74
jgiven-junit5/src/test/java/com/tngtech/jgiven/junit5/test/PendingTest.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,74 @@ | ||
package com.tngtech.jgiven.junit5.test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.tngtech.jgiven.annotation.ScenarioStage; | ||
import com.tngtech.jgiven.junit5.SimpleScenarioTest; | ||
|
||
import com.tngtech.jgiven.annotation.ExpectedScenarioState; | ||
import com.tngtech.jgiven.annotation.Pending; | ||
import com.tngtech.jgiven.report.model.ExecutionStatus; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class PendingTest extends SimpleScenarioTest<PendingTest.PendingTestSteps> { | ||
|
||
@ScenarioStage | ||
PendingTest.PendingTestStepsWithRequiredField pendingTestStepsWithRequiredField; | ||
|
||
@Test | ||
@Pending | ||
public void required_does_not_fail_for_pending_scenarios() { | ||
pendingTestStepsWithRequiredField.some_action(); | ||
|
||
assertThat( getScenario().getScenarioCaseModel().getExecutionStatus() ).isEqualTo(ExecutionStatus.SCENARIO_PENDING); | ||
} | ||
|
||
@Test | ||
@Pending(executeSteps = true) | ||
public void failing_steps_are_reported_as_pending_if_execute_steps_is_true() { | ||
when().some_failing_action(); | ||
|
||
assertThat( getScenario().getScenarioCaseModel().getExecutionStatus() ).isEqualTo(ExecutionStatus.SCENARIO_PENDING); | ||
} | ||
|
||
@Test | ||
public void failing_steps_are_reported_as_pending_if_execute_steps_is_true_on_step_method() { | ||
when().some_failing_action_with_pending_annotation(); | ||
|
||
assertThat( getScenario().getScenarioCaseModel().getExecutionStatus() ).isEqualTo(ExecutionStatus.SCENARIO_PENDING); | ||
} | ||
|
||
@Test | ||
@Pending(failIfPass = true) | ||
public void failing_tests_with_failIfPass_are_reported_as_pending() { | ||
when().some_failing_action(); | ||
|
||
assertThat( getScenario().getScenarioCaseModel().getExecutionStatus() ).isEqualTo(ExecutionStatus.SCENARIO_PENDING); | ||
} | ||
|
||
public static class PendingTestStepsWithRequiredField { | ||
@ExpectedScenarioState(required = true) | ||
String someState; | ||
|
||
public PendingTestStepsWithRequiredField some_action() { | ||
return this; | ||
} | ||
} | ||
|
||
public static class PendingTestSteps { | ||
@ExpectedScenarioState | ||
String someState; | ||
|
||
public PendingTestSteps some_failing_action() { | ||
assertThat(someState).isNotNull(); | ||
return this; | ||
} | ||
|
||
@Pending(executeSteps = true) | ||
public PendingTestSteps some_failing_action_with_pending_annotation() { | ||
assertThat(someState).isNotNull(); | ||
return this; | ||
} | ||
|
||
} | ||
} |
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
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