-
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.
TestNG: do not throw exceptions in the test listener, but assign them…
… to the test result (fixes #123)
- Loading branch information
Jan Schäfer
committed
Sep 25, 2015
1 parent
cab8b6c
commit 74af32f
Showing
8 changed files
with
71 additions
and
2 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
23 changes: 23 additions & 0 deletions
23
jgiven-tests/src/main/java/com/tngtech/jgiven/tests/FailingCasesTestNgTest.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,23 @@ | ||
package com.tngtech.jgiven.tests; | ||
|
||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import com.tngtech.jgiven.testng.ScenarioTest; | ||
|
||
public class FailingCasesTestNgTest extends ScenarioTest<GivenTestStage, WhenTestStage, ThenTestStage> { | ||
|
||
@DataProvider | ||
public static Object[][] booleans() { | ||
return new Object[][] { | ||
{ true }, | ||
{ false } | ||
}; | ||
} | ||
|
||
@Test( dataProvider = "booleans" ) | ||
public void failing_cases_do_not_lead_to_ignored_following_cases( boolean fail ) { | ||
given().a_failed_step( fail ); | ||
} | ||
|
||
} |
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
28 changes: 28 additions & 0 deletions
28
jgiven-tests/src/test/java/com/tngtech/jgiven/testng/DataProviderTestNgTest.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,28 @@ | ||
package com.tngtech.jgiven.testng; | ||
|
||
import org.junit.Test; | ||
|
||
import com.tngtech.jgiven.GivenScenarioTest; | ||
import com.tngtech.jgiven.JGivenScenarioTest; | ||
import com.tngtech.jgiven.report.model.ExecutionStatus; | ||
import com.tngtech.jgiven.tags.FeatureTestNg; | ||
import com.tngtech.jgiven.tags.Issue; | ||
import com.tngtech.jgiven.testframework.TestFramework; | ||
import com.tngtech.jgiven.testframework.ThenTestFramework; | ||
import com.tngtech.jgiven.testframework.WhenTestFramework; | ||
|
||
@FeatureTestNg | ||
public class DataProviderTestNgTest extends JGivenScenarioTest<GivenScenarioTest<?>, WhenTestFramework<?>, ThenTestFramework<?>> { | ||
|
||
@Test | ||
@Issue( "#123" ) | ||
public void a_scenario_with_one_failing_case_still_executes_the_following_ones() { | ||
given().a_TestNG_test_with_two_cases_and_the_first_one_fails(); | ||
when().the_test_class_is_executed_with( TestFramework.TestNG ); | ||
then().the_report_model_contains_one_scenario_with_$_cases( 2 ) | ||
.and().the_scenario_has_execution_status( ExecutionStatus.FAILED ) | ||
.and().case_$_has_status( 1, ExecutionStatus.FAILED ) | ||
.and().case_$_has_status( 2, ExecutionStatus.SUCCESS ); | ||
} | ||
|
||
} |