英文:
TestNG tests are using the parameter of one test instead of their own
问题
我正在使用带有参数的TestNG,对于一个测试用例,它可以正常工作。但是一旦我添加另一个测试用例,参数就开始混乱。它们不再使用在xml文件中定义的各自的参数,而只使用一个测试用例的参数。
例如,在这个文件中,Test1和Test2都使用了值为value_1
的key
参数。以下是我在设置中如何调用这些参数(我使用@BeforeMethod,因为我们需要它来进行BrowserStack设置):
@Parameters(value={"key"})
@BeforeMethod(alwaysRun=true)
public void setup(String key) {
这种情况发生的原因是什么?我找不到其他有相同问题的人。
英文:
I'm using TestNG with parameters and it works fine for one test. But as soon as I add another test, the parameters start messing up. Instead of using their own parameters as defined in the xml file, they only use the parameter of one test.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<suite name="Test suite" >
<parameter name="key" value="value_1"/>
<test name="Test1" >
<classes>
<class name="package.Test" >
<methods>
<include name="method1" />
</methods>
</class>
</classes>
</test>
<parameter name="key" value="value_2"/>
<test name="Test2" >
<classes>
<class name="package.Test" >
<methods>
<include name="method1" />
</methods>
</class>
</classes>
</test>
</suite>
<!-- end snippet -->
For example on this file, both Test1 and Test2 use key
with value value_1
.
Here's how I call the parameters in my setup (I use @BeforeMethod because we need it for BrowserStack)
@Parameters(value={"key"})
@BeforeMethod(alwaysRun=true)
public void setup(String key) {
Is there a reason why this is happening? I can't find anyone else with the same issue
答案1
得分: 0
如果您想并行执行测试,我建议您使用下面提到的BrowserStack Sample TestNg GitHub仓库。这对我来说效果不错。
https://github.com/browserstack/testng-appium-app-browserstack
英文:
If you want to execute test in parallel I would recommend you to use BrowserStack Sample TestNg GitHub Repo as mentioned below. It worked fine for me.
https://github.com/browserstack/testng-appium-app-browserstack
专注分享java语言的经验与见解,让所有开发者获益!
评论