简体   繁体   中英

How can I execute testNG test cases in parallel on multiple machines?

I have test cases implemented for service level testing and I can execute them in parallel at suite level by using {parallel = tests} as below

<suite name="Suite_Name" parallel="tests" thread-count="10">

If I have a parent suite which comprises of children suites as below, and if I would like to create a Jenkins job to execute this parent suite, is there any way to execute these children suites in parallel[internally each child suite will execute it's test cases parallel]?

<suite>
   <suite-files>
    <suite-file path="./testSuite_1.xml"/>
    <suite-file path="./testSuite_2.xml"/>
    <suite-file path="./testSuite_3.xml"/>
    <suite-file path="./testSuite_4.xml"/>
</suite-files>

I know that selenium grid can be used if we have any web-based test cases, but the cases that I have are not web-based. They are API/service level test cases which are implemented by the customized framework using Java, TestNG and Jax-rs libraries.

This depends a lot on how you are running your tests. Let's assume that you are talking about running tests within a CI environment. I am going to use GitLab pipelines to illustrate my answer.

If you are able to run a single suite from the command line. Something like runTests suite1 . Then, in your pipeline configure a job for each test suite. By assigning all the jobs to the same stage they will run in parallel.

Based on the example your .gitlab-ci.yml would look something like this:

stages:
  - build
  - test

job 1:
  stage: build
  script: runBuild

job 2:
  stage: test
  script: runTests suite1

job 3:
  stage: test
  script: runTests suite2

job 4:
  stage: test
  script: runTests suite3

job 5:
  stage: test
  script: runTests suite4

NOTE: If you add more detail to your question feel free to drop me a message and I will update my answer accordingly. Things like the CI system, build tool, etc. would help.

Jenkins specifics

Thanks for the clarification on your environment. I haven't personally done this with Jenkins. However, Cloudbees have a blog post which talks about running jobs in parallel. Please take a look at the splitting tests section on that post, it might be just what you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM