Testing » History » Revision 3
Revision 2 (Brienne Kordis, 09/23/2022 03:22 PM) → Revision 3/6 (Brienne Kordis, 09/23/2022 03:23 PM)
# Testing
## Writing & Running Unit Tests
* Make a new file in the tests folder of the working directory. The file should be named after the file in which you are testing plus "Test"
* i.e. testing StuffFinder.php => StuffFinderTest.php
* Name the function after the function you are testing, plus "Test"
* i.e. testing findStuff() => findStuffTest()
* Can only test public functions
* if needed, step through the call stack to find a public function that is higher up in the stack than the desired private/protected function you want to test
* Whenever possible, it is best not to rely on an API call for a test, as it can introduce intentional complications that cause the test to fail when the part you're testing should pass
* To run a unit test, use this command: command, subbing in the correct path:
```
env CIVICRM_UF=UnitTests XDEBUG_SESSION=VSCODE phpunit7 (absolute path to file where test is written) --filter (name of test function)
```
*(subbing in
* *note to change the correct content within the parenthesis to what is indicated relevant to your particular test)*