Reputation: 33
I have some strange situation (for me ofcourse). I try to run framework, based on Java+TestNG+WebDriver+Maven. Here is piece of TestBase code:
@BeforeClass
@Parameters({ "browser", "version",
"platform" })
public void setUp(@Optional String browser, @Optional String version, @Optional String platform)
throws Exception {
DesiredCapabilities capability = new DesiredCapabilities();
capability.setCapability("platform", platform);
capability.setCapability("browserName", browser);
capability.setCapability("browserVersion", version);
webDriver2 = new RemoteWebDriver(new URL(
"http://127.0.0.1:4444/wd/hub"),
capability);
test.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="2" name="Suite" parallel="tests">
<test name="FireFox_MAC">
<parameter name="browser" value="firefox" />
<parameter name="version" value="41.0.2" />
<parameter name="platform" value="MAC" />
<classes>
<class name="com.testcases.AccountSuit" />
</classes>
</test>
<test name="Chrome_WIN7">
<parameter name="browser" value="chrome" />
<parameter name="version" value="42" />
<parameter name="platform" value="WINDOWS" />
<classes>
<class name="com.testcases.AccountSuit" />
</classes>
</test>
</suite>
The problem is next: when i try to run tests via IDE Eclipse pom.xml->Run As...->Maven test. all works fine. Maven runs two tests in parallel. One on FF, second on chrome. test.xml->Run As...->TestNG too. But when i try to run tests via console, using command "mvn test -Dtest=com.testcases.AccountSuit" i've got in log "can't create a new driver instance for Capabilities [{browserVersion=null, browserName=null, platform=null}]" It necessary for me to start tests with command, because i need to start them via Jenkins automatically. I'm very confused( Help please. P.S. maven-surefire-plugin version 2.18
Upvotes: 0
Views: 179
Reputation: 8531
When you are running with -Dtest only a single test is being run and the parameters that you defined in your xml are not being used. You need to either give -DsuiteXml to mvn test and specify your xml
or
define default data for browserversion, name and platform, since you have those as optional parameters.
Upvotes: 2