Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
901 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...