当尝试通过testng.xml运行具有不同参数的1个套件时,我发现参数未随testNG改变的问题
我有带有测试的base.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="BASE XML">
<test name="base test">
<classes>
<class name="testPackageL.TestClazz"/>
</classes>
</test>
</suite>
我需要将参数传递给该套件,我已经创建了multi_suite.xml并通过 suite-files 标记
将参数传递给base.xml<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite runner">
<suite-files>
<suite-file path="base.xml">
<parameter name="locale" value="se"/>
</suite-file>
<suite-file path="base.xml">
<parameter name="locale" value="dk"/>
</suite-file>
</suite-files>
</suite>
测试类的示例
package testPackageL;
import org.testng.annotations.*;
public class TestClazz {
private String locale;
@BeforeSuite
@Parameters({"locale"})
public void setUpSuite(String locale) {
this.locale = locale;
}
@Test
public void testPARAMZ() {
System.out.println("Start test with " + locale);
}
}
运行multi_suite.xml的输出:
Start test with dk
===============================================
BASE XML
Total tests run: 1, Failures: 0, Skips: 0
===============================================
Start test with dk
===============================================
BASE XML (0)
Total tests run: 1, Failures: 0, Skips: 0
===============================================
===============================================
Suite runner
Total tests run: 2, Failures: 0, Skips: 0
===============================================
参数语言环境未更改