cvetazh
про гугл sheet дата провайдеров с паралллельным доступом я не слышал - можете поделиться ?
@DataProvider(name = “гугл sheet дата провайдер”, parallel = true)
элементарный пример копирую из много где можно нагуглить испоьзует testmg.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="3" name="Suite" parallel="tests">
<test name="FirstTest">
<parameter name="browser" value="firefox"/>
<parameter name="version" value="43.0"/>
<parameter name="platform" value="MAC"/>
<classes>
<class name="example.ParallelTest"/>
</classes>
</test>
<test name="SecondTest">
<parameter name="browser" value="chrome"/>
<parameter name="version" value="51.0"/>
<parameter name="platform" value="WINDOWS"/>
<classes>
<class name="example.ParallelTest"/>
</classes>
</test>
<test name="ThirdTest">
<parameter name="browser" value="safari"/>
<parameter name="version" value="6.0"/>
<parameter name="platform" value="MAC"/>
<classes>
<class name="example.ParallelTest"/>
</classes>
</test>
</suite>
package example;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class ParallelTest {
private static final String USERNAME = "********";
private static final String ACCESS_KEY = "********";
private static final boolean mockup = true;
private Long id = (long) -1;
private WebDriver driver;
@Parameters(value = { "browser", "version", "platform" })
@BeforeClass
public void setUp(String browser, String version, String platform)
throws MalformedURLException, InterruptedException, WebDriverException {
DesiredCapabilities capability = new DesiredCapabilities();
capability.setCapability("platform", platform);
capability.setCapability("browserName", browser);
capability.setCapability("browserVersion", version);
capability.setCapability("project", "P1");
capability.setCapability("build", "1.0");
if (mockup) {
id = Thread.currentThread().getId();
System.err.println(
String.format("Creating browser driver for %s %s %s on thread %d ",
browser, version, platform, id));
} else {
driver = new RemoteWebDriver(new URL("http://" + USERNAME + ":"
+ ACCESS_KEY + "@hub.browserstack.com/wd/hub"), capability);
}
}
@Test
public void test() throws Exception {
if (mockup) {
id = Thread.currentThread().getId();
System.out.println("running test on thread: " + id);
} else {
driver.get("http://www.google.com");
System.out.println("Page title is: " + driver.getTitle());
Assert.assertEquals("Google", driver.getTitle());
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Browser Stack");
element.submit();
}
}
@AfterClass
public void tearDown() throws Exception {
if (driver != null) {
driver.quit();
}
}
}
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
...
<build>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>()
<trimStackTrace>false</trimStackTrace>
<encoding>${project.build.sourceEncoding}</encoding>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<argLine>-Dfile.encoding=${project.build.sourceEncoding} -Dparallel=tests -DthreadCount=2 </argLine>
...
(не уверен что эта часть существенна
и дает
[INFO] Running TestSuite
Creating browser driver for firefox 43.0 MAC on thread 12
Creating browser driver for safari 6.0 MAC on thread 14
Creating browser driver for chrome 51.0 WINDOWS on thread 13
running test on thread: 14
running test on thread: 13
running test on thread: 12
нам кузнец (сервлет ) не нужен - зачем нам кузнец