0

I have a selenium test which tests my target web application. I want to run the same test on Jenkins concurrently on Nightly and Staging environments. What is the better way to do that? I am ok to approach it on Jenkins or on Selenium Grid or any other way.

I explored Selenium Grid but they talk of executing different tests parallel on multiple envs. But my specific requirement is that I have to run SAME TEST CONCURRENTLY on the same browser instance or on different browser instance.

Ex: Consider this test, com.myorg.myapp.myTest.testLogin(String envURL)

I would like to run this test concurrently on Chrome (for ex) by passing Nightly and Staging URLs. At present I am running first set of tests on Nightly followed by the same tests on Staging. This takes almost a day. I need to do them concurrently to save time.

vikas
  • 1,318
  • 4
  • 16
  • 33
  • You can dockerize your application, your test and whatever you need then run them on the same time on Jenkins. – Ser Oct 17 '18 at 08:12

1 Answers1

0

You can create a testNG xml and add the same test to different suites likes this.

<suite name="mySuite" parallel="tests"> 
  <test name="thread1">
    <classes>
      <class name="test.sample.MyTest"/>
    </classes>
  </test>
  <test name="thread2">
    <classes>
      <class name="test.sample.MyTest"/>
    </classes>
  </test>
...
...
  <test name="threadN">
    <classes>
      <class name="test.sample.MyTest"/>
    </classes>
  </test>
</suite>

If you need to pass the environment add the following and access it from the code of a test as described here (http://testng.org/doc/documentation-main.html#parameters)

  <parameter name="env"  value="staging"/>

This is a simple solution yet quite ugly and harder to maintain if you need a lot of threads. Another way is to create your XML in code by implementing IAlterSuiteListener. See TestNG Parallel execution with selenium for the code sample.

Vladimir Efimov
  • 797
  • 5
  • 13