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 action
    Split tests action
  3. Select the number of groups (packages) into which you want to 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 od 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 details
    Action details
  7. The action creates environmental 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 logs
    Pipeline logs
  8. Next, you need to prepare the environment for the tests (install dependencies etc.) in the selected build action:

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

    Command tab
    Command tab

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

    Pipeline example
    Pipeline 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 progress
Pipelines 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.