PHPUnit/using PHPUnit: Difference between revisions

No edit summary
No edit summary
 
Line 1: Line 1:
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] as well as the rest of the documentation including the Appendix sections such as '''[https://docs.phpunit.de/en/9.6/configuration.html configuration].'''
{{Ambox|type=notice|text=If <code>phpunit.xml</code> or <code>phpunit.xml.dist</code> (in that order) exist in the current working directory and <code>--configuration</code> is not used, the configuration will be automatically read from that file.
The idea behind the fallback (to phpunit.xml.dist when phpunit.xml does not exist) is that phpunit.xml.dist can be checked into version control and phpunit.xml can be ignored from version control. This allows a developer to use a custom configuration without running the risk of accidentally checking it into version control.}}
== PHPUnit with VSCode ==
== PHPUnit with VSCode ==
See [[PHPUnit/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]]  


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]
The notes below are my local additions or updates as I submit edits and Pull Requests to the canonical sources.


=== Test Suites ===
=== Test Suites ===
Line 24: Line 30:
   - 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.  
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.)
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.)