Skip to content

Commit dbb6ac0

Browse files
authored
add test for an issue (fixes allure-framework#304, via allure-framework#325)
1 parent 3e9cdf4 commit dbb6ac0

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

allure-testng/src/test/java/io/qameta/allure/testng/AllureTestNgTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,32 @@ public void shouldProcessArrayParameters() {
10411041
);
10421042
}
10431043

1044+
@SuppressWarnings("unchecked")
1045+
@AllureFeatures.Fixtures
1046+
@Issue("304")
1047+
@Test(dataProvider = "parallelConfiguration")
1048+
public void shouldProcessFailedSetUps(final XmlSuite.ParallelMode mode, final int threadCount) {
1049+
final AllureResults results = runTestNgSuites(parallel(mode, threadCount), "suites/gh-304.xml");
1050+
1051+
assertThat(results.getTestResults())
1052+
.extracting(TestResult::getName, TestResult::getStatus)
1053+
.contains(tuple("skippedTest", Status.SKIPPED));
1054+
1055+
assertThat(results.getTestResultContainers())
1056+
.flatExtracting(TestResultContainer::getAfters)
1057+
.extracting(FixtureResult::getName, FixtureResult::getStatus)
1058+
.contains(tuple("afterAlways", Status.PASSED));
1059+
1060+
assertThat(results.getTestResultContainers())
1061+
.flatExtracting(TestResultContainer::getAfters)
1062+
.filteredOn("name", "afterAlways")
1063+
.flatExtracting(FixtureResult::getSteps)
1064+
.extracting(StepResult::getName)
1065+
.containsExactly(
1066+
"first", "second"
1067+
);
1068+
}
1069+
10441070
private AllureResults runTestNgSuites(final String... suites) {
10451071
final Consumer<TestNG> emptyConfigurer = testNg -> {
10461072
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2019 Qameta Software OÜ
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.qameta.allure.testng.samples;
17+
18+
import org.testng.annotations.AfterMethod;
19+
import org.testng.annotations.BeforeMethod;
20+
import org.testng.annotations.Test;
21+
22+
import static io.qameta.allure.Allure.step;
23+
24+
/**
25+
* @author charlie (Dmitry Baev).
26+
*/
27+
public class FailedSetUp {
28+
29+
@BeforeMethod
30+
public void setUp() {
31+
throw new RuntimeException("Hey");
32+
}
33+
34+
@Test
35+
public void skippedTest() {
36+
}
37+
38+
@AfterMethod(alwaysRun = true)
39+
public void afterAlways() {
40+
step("first");
41+
step("second");
42+
}
43+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
3+
4+
<suite name="Github Issues" configfailurepolicy="continue">
5+
<test name="gh-304">
6+
<classes>
7+
<class name="io.qameta.allure.testng.samples.FailedSetUp"/>
8+
</classes>
9+
</test>
10+
</suite>

0 commit comments

Comments
 (0)