Blog

Brad Wood

May 19, 2017

Spread the word


Share your thoughts

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 http://127.0.0.1:59060/tests/runner.cfm?&recurse=true&reporter=json, please wait...
TestBox v2.5.0-snapshot
---------------------------------------------------------------------------------
| Passed  | Failed  | Errored | Skipped | Time    | Bundles | Suites  | Specs   |
---------------------------------------------------------------------------------
| 16      | 0       | 0       | 0       | 132 ms  | 2       | 4       | 16      |
---------------------------------------------------------------------------------

Stopping...

CommandBox>

 

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.

{
    "testbox":{
       "runner":"http://localhost:8080/tests/runner.cfm",
       "labels":"foo",
       "bundles":"test.specs",
       "testSuites":"bar",
       "verbose":"false",
       "watchDelay":"1000",
       "watchPaths":"/models/**.cfc"
   }
}

 

 

Add Your Comment

Recent Entries

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Unfortunately, we often hear this message from clients who thought it would never happen to them... until it did. Some believed they could delay the expense of Implementing ColdFusion security best practices for one year, while others were tempted to put it off for just a few months. However, in today's rapidly evolving digital landscape, the security of web applications, including ColdFusio...

Cristobal Escobar
Cristobal Escobar
April 16, 2024
Ortus March Newsletter

Ortus March Newsletter

Welcome to Ortus Solutions’ monthly roundup, where we're thrilled to showcase cutting-edge advancements, product updates, and exciting events! Join us as we delve into the latest innovations shaping the future of technology.

Maria Jose Herrera
Maria Jose Herrera
April 01, 2024
Into the Box 2024 Last Early Bird Days!

Into the Box 2024 Last Early Bird Days!

Time is ticking, with less than 60 days remaining until the excitement of Into the Box 2024 unfolds! Don't let this golden opportunity slip away; our exclusive Early Bird Pricing is here for a limited time only, available until March 31st. Why wait? Secure your seat now and take advantage of this steal!

Maria Jose Herrera
Maria Jose Herrera
March 20, 2024