Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Paratest is a tool which enables you to run the tests in parallel, reducing the overall runtime of the test suite from several hours to one hour.

The good news is that we We have a CI system that can run tests for you in parallel mode, and at your request against different versions of PHP and different databases.

...

There is a special type of test that is intended for distribution purposes only. You can run them by adding the following to the test/phpunit/config.php file. These tests are run automatically on our CI, and they may fail when any third-party add-ons are present.

...

The test case class name must start with a component prefix (also known as frankenstyle) and must end with the _test suffix. Namespaces are not allowed.

Test The test case file name is derived from the class name; it omits the component prefix and uses the _test.php suffix.

...

  • All calls to tearDown and tearDownAfterClass must call the matching parent method.

  • PHP notices/warnings/errors will not auto-convert into exceptions.
    This feature was removed from PHPUnit with no replacement, tests that rely on checking for PHP warnings were adjusted.

  • Some functions in the Mocking API have been removed.
    Functions like onConsecutiveCalls have been removed. The full list can be seen on in the deprecations list.

  • testcase_autoloader, advanced_testcase and basic_testcase have been removed.
    The autoloader is no longer relevant as our tests must be named correctly. The other base testcase classes have been deprecated since Totara 14 and are now gone.

  • Assertions assertTag and assertNotTag are deprecated.
    These still exist for some legacy tests but please do not use them on any new tests.

  • Data providers must return examples in the correct format.

    A collection of an array of parameters must be returned, with each entry optionally being keyed by a unique message explaining the test case. The parameters array may also be keyed, and if it is the keys must match the testcase method signature.

    Code Block
    languagephp
    // Simple Example
    public static function my_data_provider(): array {
    	return [
    		['propA Value', 'propB Value', 'propC Value'], // Test 1
    		['propA Value', 'propB Value', 'propC Value'], // Test 2
    	];
    }
    // Named Entries
    public static function my_data_provider(): array {
    	return [
    		'data label 1' => ['propA Value', 'propB Value', 'propC Value'],
    		'data label 2' => ['propA Value', 'propB Value', 'propC Value'],
    	];
    }
    // Named Properties
    public static function my_data_provider(): array {
    	return [
    		[
    			'propA' => 'propA Value', 
    			'propB' => 'propB Value', 
    			'propC' => 'propC Value'
    		],
    		[
    			'propA' => 'propA Value', 
    			'propB' => 'propB Value', 
    			'propC' => 'propC Value'
    		],
    	];
    }
    // Named & Labelled
    public static function my_data_provider(): array {
    	return [
    		'data label 1' => [
    			'propA' => 'propA Value', 
    			'propB' => 'propB Value', 
    			'propC' => 'propC Value'
    		],
    		'data label 2' => [
    			'propA' => 'propA Value', 
    			'propB' => 'propB Value', 
    			'propC' => 'propC Value'
    		],
    	];
    }

...

There is a visual bug when running tests in parallel with ParaTestParatest, where if a single test class has a large number of steps in it (calculated across all the test cases) then it will print some accidental output during the progress report.

...