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

Ortus February Newsletter 2024

Ortus February Newsletter 2024

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
March 06, 2024
Unveiling the Future of CFML Development - 3rd Round of Sessions

Unveiling the Future of CFML Development - 3rd Round of Sessions

Welcome back to our journey into the future of CFML development! As excitement continues to build for Into the Box 2024, we're thrilled to bring you the latest updates on what promises to be a transformative event. Continuing our blog post series, let's delve deeper into the third wave of session releases and discover the key surprises awaiting attendees. Learn More

Maria Jose Herrera
Maria Jose Herrera
March 01, 2024
Elevate Your ColdBox Experience and Skills

Elevate Your ColdBox Experience and Skills

We're thrilled to announce a significant overhaul of our ColdBox training experience to ensure it's nothing short of extraordinary! We've listened closely to your feedback and made significant improvements geared towards transforming you into a ColdBox superhero. Learn What's New!

Maria Jose Herrera
Maria Jose Herrera
February 20, 2024