This repository has been archived by the owner on Jan 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
methods that are excluded by a "groups" filter must not be included i…
…n the report (fixes #880)
- Loading branch information
Showing
4 changed files
with
151 additions
and
1 deletion.
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
50 changes: 50 additions & 0 deletions
50
...g-adaptor/src/test/java/ru/yandex/qatools/allure/testng/AllureTestListenerGroupsTest.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,50 @@ | ||
package ru.yandex.qatools.allure.testng; | ||
|
||
import static java.util.Collections.*; | ||
import static javax.xml.bind.JAXB.unmarshal; | ||
import static org.hamcrest.Matchers.*; | ||
import static org.junit.Assert.*; | ||
import static ru.yandex.qatools.allure.commons.AllureFileUtils.*; | ||
|
||
import java.io.*; | ||
import java.util.*; | ||
import org.junit.*; | ||
import org.junit.rules.TemporaryFolder; | ||
import org.testng.TestNG; | ||
import ru.yandex.qatools.allure.model.*; | ||
import ru.yandex.qatools.allure.utils.AllureResultsUtils; | ||
|
||
public class AllureTestListenerGroupsTest { | ||
|
||
@Rule | ||
public TemporaryFolder folder = new TemporaryFolder(); | ||
private File resultsDir; | ||
|
||
@Before | ||
public void setUp() throws IOException { | ||
resultsDir = folder.newFolder(); | ||
AllureResultsUtils.setResultsDirectory(resultsDir); | ||
} | ||
|
||
@Test // see https://github.com/allure-framework/allure-core/issues/880 | ||
public void reportContainsTestForGroups() { | ||
// GIVEN: an TestNG suite with groups | ||
TestNG testNG = new TestNG(false); | ||
testNG.setTestSuites(singletonList(getClass().getClassLoader().getResource("suite-groups.xml").getFile())); | ||
|
||
// WHEN: executing | ||
testNG.run(); | ||
|
||
// THEN: report only contains results for included groups | ||
List<File> files = listTestSuiteFiles(resultsDir); | ||
assertThat(files, hasSize(1)); | ||
File file = files.get(0); | ||
TestSuiteResult result = unmarshal(file, TestSuiteResult.class); | ||
assertThat(result.getTestCases(), hasSize(2)); | ||
List<String> status = new ArrayList<>(); | ||
for (TestCaseResult test : result.getTestCases()) { | ||
status.add(test.getName() + ":" + test.getStatus()); | ||
} | ||
assertThat(status, containsInAnyOrder("inactiveIncludedTest:PENDING", "activeIncludedTest:PASSED")); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
allure-testng-adaptor/src/test/java/ru/yandex/qatools/allure/testng/testdata/GroupTest.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,34 @@ | ||
package ru.yandex.qatools.allure.testng.testdata; | ||
|
||
import static org.hamcrest.CoreMatchers.*; | ||
import static org.junit.Assert.*; | ||
import static org.testng.Assert.fail; | ||
|
||
import org.testng.annotations.*; | ||
|
||
public class GroupTest { | ||
|
||
@Test | ||
public void activeTest() { } | ||
|
||
@Test(enabled = false) | ||
public void inactiveTest() { } | ||
|
||
@Test(groups = "include") | ||
public void activeIncludedTest() { } | ||
|
||
@Test(groups = "include", enabled = false) | ||
public void inactiveIncludedTest() { } | ||
|
||
@Test(groups = "exclude") | ||
public void activeExcludedTest() { } | ||
|
||
@Test(groups = "exclude", enabled = false) | ||
public void inactiveExcludedTest() { } | ||
|
||
@Test(groups = {"include", "exclude"}) | ||
public void activeIncludedExcludedTest() { } | ||
|
||
@Test(groups = {"include", "exclude"}, enabled = false) | ||
public void inactiveIncludedExcludedTest() { } | ||
} |
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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> | ||
<suite name="Test suite with groups"> | ||
<test name="Test with groups"> | ||
<groups> | ||
<run> | ||
<include name="include"/> | ||
<exclude name="exclude"/> | ||
</run> | ||
</groups> | ||
<classes> | ||
<class name="ru.yandex.qatools.allure.testng.testdata.GroupTest"/> | ||
</classes> | ||
</test> | ||
</suite> |