Search code examples
erlangcommon-test

Erlang - Skip test suite immediately in common test


I know the way to skip test suite is:

Let init_per_suite function return {skip, reason} value. But It will execute all commands in the init_per_suite function before skip.

I want to skip test suite immediately when a condition is met.


Solution

  • Maybe just test the condition early in init_per_suite and abort:

    init_per_suite(Config) ->
        case abort_condition_met() of
            true ->
                {skip,abort_condition_met};
            false ->
                %% run functions
                Config
        end.
    

    Or you can omit the testsuite from the command to start common_test. For example, if you run common_test using ct_run, create a config which suites your requirements.