0
votes

I have installed phpunit in a wamp server using pear in the following directory structure C:\Easy-PHP\pear\PHPUnit.

PHPUnit runs fine, I can run it from globally i.e. c:\phpUnit

My question is how do I run tests from within directories?

For example:

I have classes to be tested in c:\Users\j.bloggs\workspace\assets\project-name\classes\myClass.php

I have tests in c:\Users\j.bloggs\workspace\assets\project\tests\myClassTest.php

How do I set up using PHPUnit to run tests in this way? I have seen information on phpunit.xml and bootstrap.php, how do I implement these? I have not found anything clear on this.

Thanks for any help.

1

1 Answers

4
votes

When you run PHPUnit from the command line, it first looks in its existing directory for any phpunit.xml file to provide settings, and if it contains the path to a bootstrap file, then that bootstrap file will be executed beforehand.

The bootstrap file should be able to provide the source of the classes to be tested (by setting them up, if the test files themselves don't).

After that, it recursively looks in directories in the current working directory, for files that follow the naming convention XXXTest.php, then executes them.

Simply put, just navigate to your test folders and run phpunit.