我想在一个浏览器中执行我的所有测试用例(我使用testng和maven来执行测试用例)我实现@BeforeSuite
和@AfterSuite
一切都没问题,但问题是什么时候我想添加一个参数"浏览器"我的testng.xml错误是:
参数'浏览器' @Configuration对方法testBeforeSuite要求但未标记为@Optional或已定义 在F:\ workspace \ my-app \ browser.xml
中
我有下一个testng.xml
我只希望参数browser
仅适用于TestConfig而不适用于其他测试用例
我尝试用:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="Test">
<parameter name="browser" value="firefox"/>
<classes>
<class name="com.mycompany.app.TestConfig"/>
</classes>
</test>
<test name="Test2">
<classes>
<class name="com.mycompany.app.TestOrder"/>
<class name="com.mycompany.app.TestDatabase"/>
</classes>
</test>
</suite>
但显示相同的错误。 我在testng中查找了exclude参数,但是我找不到任何东西 有没有办法在一个测试用例中使用参数浏览器运行一套测试用例? (仅限配置)
答案 0 :(得分:0)
根据信息猜测,我会说您的testBeforeSuite
方法需要浏览器参数。
您是否尝试将该参数应用于套件而不是测试?
答案 1 :(得分:0)
Hi this is kumar.
You have declared the parameters in the testng.xml
but u should read the parameter name and vaue in testng file.
In testng file u have to use the @parameters annotatin .following code expalins
public class Test
{
@parameters(browser)
@Test
public void runTest(string value)
{
WebDriver driver;
if(value.equals("firefox"))
{
driver= new FirefoxDriver();
}
}
}
&#13;