TestNG 可以运行多个套件吗? [英] Can TestNG run multiple suites?

查看:33
本文介绍了TestNG 可以运行多个套件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Selenium 和 TestNG 测试 web-ui.我有一个包含许多测试类的测试套件.我有一个 @BeforeSuite 方法,它也有一个 @Parameters 注释,这个方法接收作为参数的 浏览器,Selenium 测试将在其中运行,执行以下几行:

I am testing a web-ui using Selenium and TestNG. I have a test suite with many test classes in it. I have a @BeforeSuite method which also has a @Parameters annotation, this method receives as a parameter the browser in which the Selenium test will be run, executing the lines:

selenium = new DefaultSelenium("localhost", 4444, browser, "http://localhost:8099");
selenium.start();

我用来运行测试套件的 XML 是:

The XML I'm using to run the test suite is:

<suite name="suite">
<parameter name = "browser" value = "*firefox"/>
 <test name="allTests">
  <classes>
   <class name="test.webui.MemcachedDeploymentTest" />
  </classes>
 </test> 
</suite>

这工作正常,测试在 Firefox 中运行.我的问题是,我想以某种方式再次运行该套件,在第一次运行完成后立即运行,但这次使用 Chrome 作为浏览器.我现在有 2 个 XML 套件,一个使用 Chrome,一个使用 Firefox.有没有办法自动一个接一个地运行这些测试套件?也许使用第三个 XML?

This works fine and the test runs in Firefox. my problem is that i would like to somehow run this suite again, immediately after the first run finishes, but this time with Chrome as the browser. i now have 2 XML suites, one with Chrome and one with Firefox. Is there any way to run these test suites one after the other automatically? maybe using a third XML?

推荐答案

你可以像这样运行 testNG 套件:

You can runt testNG suites like this:

<suite name="allSuites">
  <suite-files>
    <suite-file path="suite1.xml" />
    <suite-file path="suite2.xml" />
    ...
  </suite-files>
</suite>

您还可以与 ant 任务并行运行这些套件.如果你愿意,我会提供蚂蚁的示例代码.

You can also run those suites in parallel with an ant task. If you want I ll provide example code for ant.

这篇关于TestNG 可以运行多个套件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆