[英]Maven don't read parameters from test.xml
I have some strange situation (for me ofcourse). 我有一些奇怪的情况(当然对我来说)。 I try to run framework, based on Java+TestNG+WebDriver+Maven.
我尝试运行基于Java + TestNG + WebDriver + Maven的框架。 Here is piece of TestBase code:
这是一段TestBase代码:
@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: 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. 接下来的问题是:当我尝试通过IDE Eclipse pom.xml-> Run As ...-> Maven测试运行测试时。 all works fine.
一切正常。 Maven runs two tests in parallel.
Maven并行运行两个测试。 One on FF, second on chrome.
一在FF上,第二在镀铬上。 test.xml->Run As...->TestNG too.
test.xml-> Run As ...-> TestNG也是如此。 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.
但是,当我尝试通过控制台使用命令“ mvn test -Dtest = com.testcases.AccountSuit”运行测试时,我在日志中“无法为Capabilities [{browserVersion = null,browserName = null ,platform = null}]“对于我来说,必须使用命令启动测试,因为我需要通过Jenkins自动启动它们。 I'm very confused( Help please. PS maven-surefire-plugin version 2.18
我很困惑(请帮助。PS maven-surefire-plugin版本2.18
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. 使用-Dtest运行时,仅运行单个测试,并且不使用您在xml中定义的参数。 You need to either give -DsuiteXml to mvn test and specify your xml
您需要给-DsuiteXml进行mvn测试并指定xml
or 要么
define default data for browserversion, name and platform, since you have those as optional parameters. 定义浏览器版本,名称和平台的默认数据,因为您将这些数据作为可选参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.