Skip to content

Commit

Permalink
Tidy (JsonTestCaseScriptRunnerTest), refs 1981, 2050
Browse files Browse the repository at this point in the history
  • Loading branch information
mwjames committed Dec 10, 2016
1 parent 97bcab8 commit 5c6455a
Show file tree
Hide file tree
Showing 193 changed files with 642 additions and 390 deletions.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -87,8 +87,9 @@
"phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist",
"unit": [
"composer dump-autoload",
"php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --testsuite=semantic-mediawiki-unit"
"composer phpunit -- --testsuite=semantic-mediawiki-unit"
],
"integration": "composer phpunit -- --testsuite=semantic-mediawiki-integration",
"cs-standalone": [
"composer validate --no-interaction",
"vendor/bin/phpcs src/* includes/* tests/* --standard=phpcs.xml --extensions=php -sp"
Expand Down
18 changes: 13 additions & 5 deletions tests/README.md
Expand Up @@ -50,14 +50,20 @@ For a short introduction on "How to write a test for Semantic MediaWiki", have a

### Test cases

The use of `MediaWikiTestCase` is discouraged as its binds tests and the test environment to MediaWiki. Generally it is best to use `PHPUnit_Framework_TestCase` and in case where a MW database connection is required `MwDBaseUnitTestCase` should be used instead.
The use of `MediaWikiTestCase` is discouraged as its binds tests and the test
environment to MediaWiki. Generally it is best to use `PHPUnit_Framework_TestCase`
and in case where a MW database connection is required `MwDBaseUnitTestCase`
should be used instead.

* `QueryPrinterTestCase` base class for all query and result printers
* `SpecialPageTestCase` derives from `SemanticMediaWikiTestCase`

## Integration tests

Integration tests are vital to confirm expected behaviour of a component from an integrative perspective that occurs through the interplay with its surroundings. `SMW\Tests\Integration\` contains most of the tests that target the validation of reciprocity with MediaWiki and/or other services such as:
Integration tests are vital to confirm expected behaviour of a component from an
integrative perspective that occurs through the interplay with its surroundings.
`SMW\Tests\Integration\` contains most of the tests that target the validation of
reciprocity with MediaWiki and/or other services such as:

- `SPARQLStore` ( `fuseki`, `virtuoso`, `blazegraph`, or `sesame` )
- Extensions such as `SM`, `SESP`, `SBL` etc.
Expand All @@ -72,7 +78,7 @@ down process for each test execution.

The script like test definition was introduced to lower the barrier of understanding
of what is being tested by using a wikitext notation (internally PHPUnit is used
by the `ByJsonTestCaseProvider` to run/provide the actually test).
by the `JsonTestCaseScriptRunner` to run/provide the actually test).

A new test file (with different test cases) is automatically added by a `TestCaseRunner`
as soon as it is placed within the location expected by the runner.
Expand Down Expand Up @@ -142,15 +148,17 @@ it is recommended to fix the settings for a test by adding something like:
}
</pre>

A complete list of available `json` test files can be found [here](https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests/phpunit/Integration/ByJsonScript/README.md).
A complete list of available `json` test files can be found [here](https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests/phpunit/Integration/JSONScript/README.md).

## Benchmark tests

For details, please have a look at the [benchmark guide](phpunit/Benchmark/README.md) document.

# JavaScript (QUnit)

Running qunit tests in connection with MediaWiki requires to execute [Special:JavaScriptTest][mw-qunit-testing]. QUnit tests are currently not executed on Travis (see [#136][issue-136]).
Running qunit tests in connection with MediaWiki requires to execute
[Special:JavaScriptTest][mw-qunit-testing]. QUnit tests are currently not
executed on Travis (see [#136][issue-136]).

# Miscellaneous
* [Writing testable code](https://semantic-mediawiki.org/wiki/Help:Writing_testable_code)
Expand Down
11 changes: 10 additions & 1 deletion tests/autoloader.php
Expand Up @@ -57,10 +57,19 @@
$autoloader->addClassMap( array(
'SMW\Tests\TestEnvironment' => __DIR__ . '/phpunit/TestEnvironment.php',
'SMW\Tests\MwDBaseUnitTestCase' => __DIR__ . '/phpunit/MwDBaseUnitTestCase.php',
'SMW\Tests\ByJsonTestCaseProvider' => __DIR__ . '/phpunit/ByJsonTestCaseProvider.php',
'SMW\Tests\JsonTestCaseScriptRunner' => __DIR__ . '/phpunit/JsonTestCaseScriptRunner.php',
'SMW\Tests\JsonTestCaseFileHandler' => __DIR__ . '/phpunit/JsonTestCaseFileHandler.php',
'SMW\Tests\JsonTestCaseContentHandler' => __DIR__ . '/phpunit/JsonTestCaseContentHandler.php',
'SMW\Test\QueryPrinterTestCase' => __DIR__ . '/phpunit/QueryPrinterTestCase.php',
'SMW\Test\QueryPrinterRegistryTestCase' => __DIR__ . '/phpunit/QueryPrinterRegistryTestCase.php',
) );

/**
* @since 2.5
*
* Shoudl be removed once all external references have been renamed.
*/
class_alias( 'SMW\Tests\JsonTestCaseScriptRunner', 'SMW\Tests\ByJsonTestCaseProvider' );


return $autoloader;

0 comments on commit 5c6455a

Please sign in to comment.