Всем привет! Тема не новая, нашел только эту Параллельный запуск тестов junit + Maven
В общем создал черновик чтобы отладить процесс и понять как maven-surefire-plugin работает, класс выглядит так:
public class TestThreads {
@Before
public void setup() {
BrowserConfiguration.setUpLocale("chrome", "1400x800", true);
}
@Test
public void test1() {
open("https://mvnrepository.com/artifact/log4j/log4j/1.2.17");
$("#maincontent > table > tbody > tr:nth-child(1) > th").waitUntil(Condition.appears, 120000);
$("#maincontent > table > tbody > tr:nth-child(1) > th").shouldBe(Condition.text("License"));
assertEquals("Maven Repository: log4j » log4j » 1.2.17", title());
out.println("test1 Passed");
}
@Test
public void test2() {
open("https://mvnrepository.com/");
$("#maincontent > h1").waitUntil(Condition.appears, 120000);
$("#maincontent > h1").shouldBe(Condition.text("What's New in Maven"));
assertEquals("Maven Repository: Search/Browse/Explore", title());
out.println("test2 Passed");
}
@Test
public void test3() {
open("https://mvnrepository.com/artifact/log4j/log4j/1.2.17");
$("#maincontent > table > tbody > tr:nth-child(1) > th").waitUntil(Condition.appears, 120000);
$("#maincontent > table > tbody > tr:nth-child(1) > th").shouldBe(Condition.text("License"));
assertEquals("Maven Repository: log4j » log4j » 1.2.17", title());
out.println("test3 Passed");
}
@Test
public void test4() {
open("https://mvnrepository.com/artifact/log4j/log4j/1.2.17");
$("#maincontent > table > tbody > tr:nth-child(1) > th").waitUntil(Condition.appears, 120000);
$("#maincontent > table > tbody > tr:nth-child(1) > th").shouldBe(Condition.text("License"));
assertEquals("Maven Repository: log4j » log4j » 1.2.17", title());
out.println("test4 Passed");
}
@Test
public void test5() {
open("https://mvnrepository.com/");
$("#maincontent > h1").waitUntil(Condition.appears, 120000);
$("#maincontent > h1").shouldBe(Condition.text("What's New in Maven"));
assertEquals("Maven Repository: Search/Browse/Explore", title());
out.println("test5 Passed");
}
@Test
public void test6() {
open("https://mvnrepository.com/artifact/log4j/log4j/1.2.17");
$("#maincontent > table > tbody > tr:nth-child(1) > th").waitUntil(Condition.appears, 120000);
$("#maincontent > table > tbody > tr:nth-child(1) > th").shouldBe(Condition.text("License"));
assertEquals("Maven Repository: log4j » log4j » 1.2.17", title());
out.println("test6 Passed");
}
@Test
public void test7() {
open("https://mvnrepository.com/artifact/log4j/log4j/1.2.17");
$("#maincontent > table > tbody > tr:nth-child(1) > th").waitUntil(Condition.appears, 120000);
$("#maincontent > table > tbody > tr:nth-child(1) > th").shouldBe(Condition.text("License"));
assertEquals("Maven Repository: log4j » log4j » 1.2.17", title());
out.println("test7 Passed");
}
@Test
public void test8() {
open("https://mvnrepository.com/");
$("#maincontent > h1").waitUntil(Condition.appears, 120000);
$("#maincontent > h1").shouldBe(Condition.text("What's New in Maven"));
assertEquals("Maven Repository: Search/Browse/Explore", title());
out.println("test8 Passed");
}
@Test
public void test9() {
open("https://mvnrepository.com/artifact/log4j/log4j/1.2.17");
$("#maincontent > table > tbody > tr:nth-child(1) > th").waitUntil(Condition.appears, 120000);
$("#maincontent > table > tbody > tr:nth-child(1) > th").shouldBe(Condition.text("License"));
assertEquals("Maven Repository: log4j » log4j » 1.2.17", title());
out.println("test9 Passed");
}}
В pom.xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin}</version>
<configuration>
<forkCount>2</forkCount>
<reuseForks>true</reuseForks>
<parallel>all</parallel>
<threadCount>2</threadCount>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
</plugins>
В итоге если из терминала запускать
mvn -Dtest=TestThreads test
То открывется 9 копий браузера, на каждый тест по копии.
Как можно ограничить кол-во запускаемых браузеров, например я хочу только 4 копии ?