Running bats-core Tests

There are several ways to run bats-core tests:

How To Run All Tests in a Directory

Choose Run ‘All tests’ in the context menu on the directory. This creates a new bats-core run configuration to execute all tests in all .bats files in this directory and all sub directories.

How To Run All Tests in a File

Click on the first green arrow gutter icon in the file and choose All tests in the context menu. This creates and runs a new bats-core run configuration for the current file.

How To Run a Specific Test

Click on the green arrow gutter icon in the file and choose Run ‘your test name’ in the context menu. This creates and runs a new bats-core run configuration for only this function.

bats-core Run Configurations

bats-core tests are run via “Run Configurations”, which is a feature of your JetBrains IDE. Please refer to JetBrains’s help to learn more about it.

Properties

You can configure these properties for bats-core run configurations. They correspond to the available command line options of bats-core.

Test data path
The file to a .bats file or a directory, which contains .bats files.
Test name pattern
A regular expression to define the tests, which should be executed in the source defined by Test data path .
Recursive
If this is enabled and Test data path points to a directory, then .bats files will be searched recursively in the directory and all sub directories. Disable this if you only want to limit the test search to just the directory you specified.
Number of parallel jobs
This defines how many tests are run in parallel. The GNU parallel command has to be installed to use this feature.
Interpreter path
This defines the shell to run the bats-core test runner. bats-core is a Bash script and needs an interpreter to run. By default BashSupport Pro lets your operating system choose the interpreter. Because this isn’t possible on Windows, the plugin tries to automatically locate an installation of Bash.
Use this property to specify your own path to the Bash interpreter to use.
Program arguments
The arguments to pass to the bats-core test runner. This shouldn’t be needed, but still allows you to pass special flags if you’re doing something special here.
Working directory
The working directory for the bats-core test runner. By default it’s the directory of your test data path.
Environment variables
This allows you to define the environment variables of your test runner. For example, it’s possible that some tests expect a specific environment. This allows you to define this.