Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
876 views
in Technique[技术] by (71.8m points)

selenium - Can TestNG run multiple suites?

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();

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>

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...