Define test groups

The Ballerina test framework allows grouping of tests.

Group tests

Test grouping allows us to control the execution of tests by partitioning them into groups. The Test Framework allows for a single test to have multiple groups.

A test is assigned to a group via the test configuration groups key, which accepts a string array of groups.

Example:

Group commands

Execute grouped tests

To execute groups of tests, the --groups flag is used during test execution.

$bal test --groups g1

The above results in an output of :


Compiling source
        user/Testing:0.1.0

Running Tests

        Testing
I'm a test belonging to group g1!
I'm a test belonging to groups g1 and g2!

                [pass] testFunction1
                [pass] testFunction2

                2 passing
                0 failing
                0 skipped

The groups flag supports executing multiple groups by using comma-separated arguments.

$bal test --groups g1,g2

The above results in an output of :


Compiling source
        user/Testing:0.1.0

Running Tests

        Testing
I'm a test belonging to group g1!
I'm a test belonging to groups g1 and g2!
I'm a test belonging to group g2!

                [pass] testFunction1
                [pass] testFunction2
                [pass] testFunction3

                3 passing
                0 failing
                0 skipped

Disable grouped tests

To skip the execution of certain groups of tests, the --disable-groups flag is used during test execution.

bal test --disable-groups g2

The above results in an output of :

Compiling source
        user/Testing:0.1.0

Running Tests

        Testing
I'm a test belonging to group g1!

                [pass] testFunction1

                1 passing
                0 failing
                0 skipped