Project

General

Profile

Testing » History » Version 5

Brienne Kordis, 09/23/2022 03:29 PM

1 1 Brienne Kordis
# Testing
2
3
## Writing & Running Unit Tests
4
* 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"
5
    * i.e. testing StuffFinder.php => StuffFinderTest.php
6
* Name the function after the function you are testing, plus "Test"
7
    * i.e. testing findStuff() => findStuffTest()
8
* Can only test public functions
9
    * 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
10 3 Brienne Kordis
* To run a unit test, use this command:
11 1 Brienne Kordis
```
12
env CIVICRM_UF=UnitTests XDEBUG_SESSION=VSCODE phpunit7 (absolute path to file where test is written) --filter (name of test function)
13
```
14 4 Brienne Kordis
*(subbing in the correct content within the parenthesis to the relevant info for your particular test)*