Running Code Coverage
Fusion Reactor
If you don't have FusionReactor installed, you can do so very easily in CommandBox like so:
That's it! All servers you start now will have FusionReactor configured. You can open FusionReactor's web console via the menu item in your server's tray icon. Note, the FusionReactor web admin is not required to get TestBox code coverage.
TestBox 3.x+
To get the latest version of TestBox into a new project, you can install it via CommandBox like so:
The --saveDev
flag will store TestBox as a development dependency.
Test Suite
If you don't have test suite yet, let's install a ColdBox sample app to play with. TestBox does not require ColdBox to work, but the mechanics of the test runner itself are identical so this is the easiest way to get one running. Run these CommandBox commands in an empty directory.
Inside your directory will be a folder called /tests
which has our test runner /tests/runner.cfm
. You will need to open your runner.cfm and default code coverage enabled to true.
Run your Test Suite
All you need to do now is run your test suite. You can do so by hitting /tests/runner.cfm
in the URL of your browser, or use the testbox run
command in CommandBox.
You don't need to configure anything for code coverage to work. TestBox will auto-detect if FusionReactor is installed on your server and will generate the code coverage results for you. In the output of your test reporter, you will see a percentage to represents the number of lines of code (LOC) which were executed divided by the total number of lines of code. Note, code coverage only counts executable lines of code against you, so comments, whitespace, or HTML do not count as an executable LOC.
Keep reading in the next section to find out how to configure the details of code coverage to only look at the files you want and also how to generate the Code Coverage Browser.