Test script caching
To be reliable, tests must be consistent and repeatable. To ensure this, the SDK will cache the results of successful extractions into a test script that can be reused in subsequent test runs.
Customizing the cache directory
You can configure the location of the cache directory by changing the cacheDir
parameter:
$this->carbonateSdk = new SDK(
$this->browser,
// This will store the files in a directory named after the test file
__DIR__ .'/'. pathinfo(__FILE__, PATHINFO_FILENAME),
// ...
);
This directory, and the resulting cached test scripts, should be committed to your source control system.
Invalidating the cache
When you change your HTML significantly, your tests will start to fail since the tests are testing the old HTML. If this is expected, you can invalidate the cache by deleting the appropriate directory. This will force the SDK to re-extract a new test script the next time it is run.
Invalidating the cache of an entire test case
For example, if you wish to invalidate the cache for the tests contained within tests/MyTest.py
, you should delete the tests/MyTest
directory:
rm -rf tests/MyTest
Invalidating the cache of a single test
If you only wish to invalidate a single test and not the entire test case, you can delete the sub-directory that matches your test name.
For example, if you wish to invalidate the cache for the testItShouldDoMyAction
test, you should delete the tests/MyTest/testItShouldDoMyAction
directory:
rm -rf tests/MyTest/testItShouldDoMyAction
Real-world example
You can find an example of what the cache structure looks like by looking at the internal SDK tests.