New action: Run tests in parallel

February 14, 2019

New action: Run tests in parallel

Testing is essential to keeping high quality of code. However, it can also prove very time-consuming if you run a large number of tests. To reduce testing time, we have introduced a new action that will let you split your tests in packages across several actions and run them in parallel.

Please mind that splitting tests requires at least two parallel actions activated in your workspace.

How to split tests in your pipeline

  1. Create a new pipeline in your project.
  2. Choose 'Split tests' action from the actions list.

    Split tests actionSplit tests action

  3. Select the number of groups (packages) into which you want to split the tests. In this example, we'll use 3 packages.

    NOTE: make sure not to exceed the maximum number of parallel actions allowed in your account.

  4. Choose if you want to sort them alphabetically or by file size.

  5. Provide the path to the directory with test files. You can do it in two ways:

    a). Select one file with the paths to split (each path in a separate line)

    b). Use glob patterns:

    • * matches any sequence of characters (excluding path separators)
    • ** matches any sequence of characters (including path separators)
    • ? matches any single character (excluding path separators)
    • [abc] matches any character (excluding path separators) against characters in brackets
    • {foo,bar,...} matches a sequence of characters, if any of the alternatives in braces matches
  6. Once done, save the action:

    Action detailsAction details

  7. The action creates environment variables required to run the tests in parallel: $BUDDY_SPLIT_1, $BUDDY_SPLIT_2, $BUDDY_SPLIT_3, and so on. Once the pipeline is executed, you will see them in the logs.

    Pipeline logsPipeline logs

  8. Next, you need to prepare the environment for the tests (install dependencies etc.) in the selected build action:

    Command tabCommand tab

  9. The last part is adding the actions that will run the tests using the proper variable from the 'Split tests' action:

    Command tabCommand tab

    You can see we have added 3 testing actions – this is because we chose to split the tests into 3 actions: Pipeline examplePipeline example

Bonus feature: Parallel deployments

Once your tests have passed, you can prepare a production build of your application and deploy it to several servers at once using parallel actions:

Pipelines in progressPipelines in progress

Buddy is 100% customer driven. If there’s a feature or integration you miss, let us know in the comments below or directly at support@buddy.works.

Share:

Alexander Kus

Alexander Kus

Customer Success Manager

A story-teller and conversation-lover, Alexander decided to invest his skills to help his friends at Buddy transform the cold language of patch notes into exciting narratives. Also: an avid gamer, hip-hop DJ, Liverpool FC fan, absentminded husband, and the father of two.