There is a new command in town in the CommandBox 3.7 snapshot build.  If you want to get the current snapshot build of CommandBox 3.7 to try this out, and play with it, simply run the following command and it will direct you to the latest bleeding edge download page:

CommandBox> upgrade --latest

What does it do?

This command is called testbox watch and it is similar to testbox run which can be used to run your projects unit or integration tests.  The difference is that testbox run will run your tests a single time right then, whereas the testbox watch command will stay running until you stop it with Ctrl+C.  The command will watch the files in your project for changes, and every time you save a CFC file, it will run your tests immediately, outputting the results to the console window.  This gives you instant feedback as you develop as to whether you just broke something.

CommandBox> testbox watch

Watching Files...

Executing tests via, please wait...
TestBox v2.5.0-snapshot
| Passed  | Failed  | Errored | Skipped | Time    | Bundles | Suites  | Specs   |
| 16      | 0       | 0       | 0       | 132 ms  | 2       | 4       | 16      |




If you want to see a demo of this in action, check out this screencast I made.  


Configuring Your Watcher

As usual, you can get help on any CommandBox command by adding the word "help" to the end of it.
CommandBox> testbox watch help

You will see that there are a handful of way to configure how it runs.  The watcher itself can be controlled by setting up the parameters you want in your box.json file for the project.  Here's a rundown of the configuration elements you can set.  All of these are optional except the testbox.runner.

Where are your tests located?

CommandBox> package set testbox.runner=http://localhost:8080/tests/runner.cfm

Do you want verbose test output, or compact?

CommandBox> package set testbox.verbose=false

Only runs tests with these labels

CommandBox> package set testbox.labels=foo

Choose the test suites to execute

CommandBox> package set testbox.testSuites=bar

Control how often the watcher checks the file system for changes.

CommandBox> package set testbox.watchDelay=1000

Customize exactly what files to watch for changes with a list of globbing patterns

CommandBox> package set testbox.watchPaths=/models/**.cfc

Your box.json file

So your box.json file may look something like this once you've set it up.