PHPUnit/using PHPUnit: Difference between revisions

No edit summary
No edit summary
Line 1: Line 1:
== PHPUnit with VSCode ==
See [[PHPUnit/VSCode]]
== For Semantic MediaWiki ==
== For Semantic MediaWiki ==
First, refer to the Semantic MediaWiki website for info on [[smw:Help:Using_PHPUnit|Using PHPUnit]] The notes below are my local additions or updates as I submit edits and Pull Requests to the canonical sources.
First, refer to the Semantic MediaWiki website for info on [[smw:Help:Using_PHPUnit|Using PHPUnit]] The notes below are my local additions or updates as I submit edits and Pull Requests to the canonical sources.
When using PHPUnit, you'll want to either read the --help on the console, or refer to the online version, e.g. [https://docs.phpunit.de/en/9.6/textui.html PHPUnit (v9.6) command line options]


=== Test Suites ===
=== Test Suites ===
Line 19: Line 24:
   - semantic-mediawiki-benchmark
   - semantic-mediawiki-benchmark
[[File:Grep benchmark testsuite screenshot.png|thumb|527x527px|grepping the PHPUnit configuration file for the definition of the semantic-mediawiki-benchmark test suite]]
[[File:Grep benchmark testsuite screenshot.png|thumb|527x527px|grepping the PHPUnit configuration file for the definition of the semantic-mediawiki-benchmark test suite]]
But where do those come from? What do they mean? What do they do? They are defined in <code>phpunit.xml.dist</code> so you could inspect that file for more details. In that file, we can see that the "''benchmark''" test suite will process all the PHPUnit tests defined in the '''<code>tests/phpunit/Benchmark</code>''' directory.
But where do those come from? What do they mean? What do they do? They are defined in <code>phpunit.xml.dist</code> so you could inspect that file for more details.  
 
For example, in that file, we can see that the "''[https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/tests/phpunit/Benchmark/README.md benchmark]''" test suite will process all the PHPUnit tests defined in the '''<code>tests/phpunit/Benchmark</code>''' directory. (Aside if you didn't follow the link: you should execute the benchmark tests to compare <code>master</code> against your <code>feature</code> branch to catch performance regressions.)
 
To run the Semantic MediaWiki Unit test suite, and '''output a log in HTML''' format
 
<code>php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --bootstrap tests/bootstrap.php --testsuite semantic-mediawiki-unit --testdox-html smw-unit-testdox.html</code>
 
The '''text''' log is much more readable.
 
<code>php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --bootstrap tests/bootstrap.php --testsuite semantic-mediawiki-unit --testdox-text smw-unit-testdox.txt</code>


== in a Docker Container ==
== in a Docker Container ==