Skip to content

Commit 3e35d5c

Browse files
authored
testng: add tests for the global thread pool (via #1307)
1 parent 393a0d3 commit 3e35d5c

3 files changed

Lines changed: 73 additions & 0 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,21 @@ public void parallelDataProvider() {
162162
assertThat(containers).as("Not all testng containers have been written").hasSize(3);
163163
}
164164

165+
@AllureFeatures.Parallel
166+
@Issue("1013")
167+
@Test
168+
@DisplayName("Parallel data provider tests with global thread pool")
169+
public void globalThreadPool() {
170+
final AllureResults results = runTestNgSuites("suites/global-thread-pool.xml");
171+
final List<TestResult> testResults = results.getTestResults();
172+
assertThat(testResults)
173+
.as("Not all data driven results have been written")
174+
.hasSize(50)
175+
.extracting(TestResult::getStatus)
176+
.as("All data driven tests should pass")
177+
.containsOnly(Status.PASSED);
178+
}
179+
165180
@AllureFeatures.Base
166181
@Test
167182
@DisplayName("Singe testng")
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2016-2026 Qameta Software Inc
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.DataProvider;
19+
import org.testng.annotations.Test;
20+
21+
/**
22+
* Make sure data driven tests work when the suite runs with
23+
* {@code use-global-thread-pool="true"} (see allure-java#1013).
24+
*/
25+
public class GlobalThreadPoolSample {
26+
27+
private static final int DATA_SIZE = 25;
28+
29+
@Test(dataProvider = "dp")
30+
public void firstParallelDataDrivenTest(final int value) {
31+
}
32+
33+
@Test(dataProvider = "dp")
34+
public void secondParallelDataDrivenTest(final int value) {
35+
}
36+
37+
@DataProvider(
38+
name = "dp",
39+
parallel = true
40+
)
41+
public Object[][] provide() {
42+
final Object[][] data = new Object[DATA_SIZE][1];
43+
for (int i = 0; i < DATA_SIZE; i++) {
44+
data[i][0] = i;
45+
}
46+
return data;
47+
}
48+
}
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="Global thread pool suite" parallel="methods" use-global-thread-pool="true" thread-count="4">
5+
<test name="Global thread pool test">
6+
<classes>
7+
<class name="io.qameta.allure.testng.samples.GlobalThreadPoolSample"/>
8+
</classes>
9+
</test>
10+
</suite>

0 commit comments

Comments
 (0)