File tree Expand file tree Collapse file tree 4 files changed +25
-17
lines changed
jgiven-junit5/src/main/java/com/tngtech/jgiven/junit5
jgiven-testng/src/main/java/com/tngtech/jgiven/testng
jgiven-tests/src/test/java/com/tngtech/jgiven/testframework Expand file tree Collapse file tree 4 files changed +25
-17
lines changed Original file line number Diff line number Diff line change 1
1
# Release v2.0.2
2
2
## Fixed issues
3
3
* The java 17 example projects now comes with a basic logger. [ #374 ] ( https://github.com/TNG/JGiven/issues/374 ) (thanks to rolfschumacher for reporting)
4
+ * Fixed an issue where tests that aborted in the main method were reported as
5
+ success. [ #1865 ] ( https://github.com/TNG/JGiven/issues/1865 ) (thanks to abika for reporting)
4
6
5
7
# Release v2.0.1
6
8
## Fixed issues
Original file line number Diff line number Diff line change 9
9
import com .tngtech .jgiven .impl .util .ThrowableUtil ;
10
10
import com .tngtech .jgiven .report .impl .CommonReportHelper ;
11
11
import com .tngtech .jgiven .report .model .ReportModel ;
12
- import java .util .EnumSet ;
13
12
import org .junit .jupiter .api .Assumptions ;
14
13
import org .junit .jupiter .api .Tag ;
15
14
import org .junit .jupiter .api .TestInstance ;
16
- import org .junit .jupiter .api .extension .AfterAllCallback ;
17
- import org .junit .jupiter .api .extension .AfterTestExecutionCallback ;
18
- import org .junit .jupiter .api .extension .BeforeAllCallback ;
19
- import org .junit .jupiter .api .extension .BeforeEachCallback ;
20
- import org .junit .jupiter .api .extension .ExtensionContext ;
15
+ import org .junit .jupiter .api .extension .*;
21
16
import org .junit .jupiter .api .extension .ExtensionContext .Namespace ;
22
- import org .junit .jupiter .api .extension .TestInstancePostProcessor ;
17
+
18
+ import java .util .EnumSet ;
23
19
24
20
import static com .tngtech .jgiven .report .model .ExecutionStatus .*;
25
21
@@ -87,6 +83,8 @@ public void afterTestExecution(ExtensionContext context) throws Exception {
87
83
try {
88
84
if (context .getExecutionException ().isPresent () && !ThrowableUtil .isAssumptionException (context .getExecutionException ().get ())) {
89
85
scenario .getExecutor ().failed (context .getExecutionException ().get ());
86
+ } else if (context .getExecutionException ().isPresent () && ThrowableUtil .isAssumptionException (context .getExecutionException ().get ())) {
87
+ scenario .getExecutor ().aborted (context .getExecutionException ().get ());
90
88
}
91
89
scenario .finished ();
92
90
Original file line number Diff line number Diff line change 1
1
package com .tngtech .jgiven .testng ;
2
2
3
- import static java .util .Arrays .asList ;
4
-
5
3
import com .tngtech .jgiven .base .ScenarioTestBase ;
6
4
import com .tngtech .jgiven .exception .FailIfPassedException ;
7
5
import com .tngtech .jgiven .impl .ScenarioBase ;
11
9
import com .tngtech .jgiven .report .impl .CommonReportHelper ;
12
10
import com .tngtech .jgiven .report .model .NamedArgument ;
13
11
import com .tngtech .jgiven .report .model .ReportModel ;
14
- import java .lang .reflect .Method ;
15
- import java .util .List ;
16
- import java .util .concurrent .ConcurrentHashMap ;
17
12
import org .testng .ITestContext ;
18
13
import org .testng .ITestListener ;
19
14
import org .testng .ITestResult ;
20
15
16
+ import java .lang .reflect .Method ;
17
+ import java .util .List ;
18
+ import java .util .concurrent .ConcurrentHashMap ;
19
+
20
+ import static java .util .Arrays .asList ;
21
+
21
22
/**
22
23
* TestNG Test listener to enable JGiven for a test class.
23
24
*/
@@ -102,6 +103,11 @@ public void onTestFailure(ITestResult paramITestResult) {
102
103
103
104
@ Override
104
105
public void onTestSkipped (ITestResult testResult ) {
106
+ ScenarioBase scenario = getScenario (testResult );
107
+ if (scenario != null ) {
108
+ scenario .getExecutor ().aborted (testResult .getThrowable ());
109
+ testFinished (testResult );
110
+ }
105
111
testFinished (testResult );
106
112
}
107
113
Original file line number Diff line number Diff line change 1
1
package com .tngtech .jgiven .testframework ;
2
2
3
- import static org .assertj .core .api .Assertions .assertThat ;
4
-
5
- import java .lang .reflect .Method ;
6
- import java .util .List ;
7
-
8
3
import com .tngtech .jgiven .annotation .ExpectedScenarioState ;
9
4
import com .tngtech .jgiven .impl .util .ReflectionUtil ;
10
5
import com .tngtech .jgiven .report .model .ExecutionStatus ;
11
6
import com .tngtech .jgiven .report .model .ScenarioModel ;
12
7
import com .tngtech .jgiven .report .model .ThenReportModel ;
13
8
import com .tngtech .jgiven .tests .TestScenarioRepository .TestScenario ;
14
9
10
+ import java .lang .reflect .Method ;
11
+ import java .util .List ;
12
+
13
+ import static org .assertj .core .api .Assertions .assertThat ;
14
+
15
15
public class ThenTestFramework <SELF extends ThenTestFramework <?>> extends ThenReportModel <SELF > {
16
16
@ ExpectedScenarioState
17
17
protected TestScenario testScenario ;
@@ -25,6 +25,8 @@ public SELF the_test_is_ignored() {
25
25
// The standard JUnit executor will report the test as passed and not ignored,
26
26
// we thus only test for not failed here
27
27
the_test_passes ();
28
+ assertThat (reportModel .getScenarios ().get (0 ).getExecutionStatus ())
29
+ .isIn (ExecutionStatus .ABORTED , ExecutionStatus .SCENARIO_PENDING , ExecutionStatus .SOME_STEPS_PENDING );
28
30
return self ();
29
31
}
30
32
You can’t perform that action at this time.
0 commit comments