Yesterday, I talked about a pull review question I got related to testing.
Today I want to bring up another testing-related question from that same review: Why did I remove some attributes from the phpunit.xml
file?
Here's an example of what I removed:
<!--original phpunit.xml-->
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<!--changed phpunit.xml-->
<testsuite name="Unit">
<directory>./tests/Unit</directory>
</testsuite>
Notice that I removed the suffix
attribute. Why? Do I want it to run all files in the ./tests/Unit
directory, even if they don't have the Test.php
suffix?
No, that's not it at all. I only removed this attribute because it was redundant.
This is the default already provided by PHPUnit. Even without specifying it, that's the behavior it will enforce.
So by removing values that are already present in the default, the configuration is more focused on things specific to this project.
And it's not that I have every default option memorized, but PHPStorm is very helpful in highlighting when something is redundant.
This does mean that you need to be more aware of defaults that change between versions of PHPUnit, but I'd argue you should be paying attention to that anyway.
Here to help,
Joel
P.S. Join the Mastering Laravel community and level up your skills by learning from other devs.