phpunitHow to use the PHPUnit cache?
PHPUnit cache is a feature that allows you to store the results of a test run in a cache file. This can be used to speed up the execution of tests, as the results of the tests do not need to be re-run.
Example code
<?php
use PHPUnit\Framework\TestCase;
class MyTest extends TestCase
{
public function testSomething()
{
// ...
}
}
To enable the cache, you need to add the following line to your phpunit.xml configuration file:
<phpunit cacheResult="true" cacheResultFile="my_test_cache.txt" />
The cacheResult
attribute enables the cache, and the cacheResultFile
attribute specifies the name of the cache file.
The cache file will be created in the same directory as the phpunit.xml file.
Helpful links
More of Phpunit
- How to use hooks in PHPUnit?
- How to skip a PHPUnit test?
- How to show warnings in PHPUnit?
- How to use the PHPUnit Framework TestCase?
- How to run tests in parallel with PHPUnit?
- How to mock a method with different arguments in PHPUnit?
- How to mock a static method with PHPUnit?
- How to install PHPUnit with a PHAR file?
- How to use PHPUnit json assert?
- How to mock a property in PHPUnit?
See more codes...