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 June 2024 Newsletter!

Ortus June 2024 Newsletter!

Welcome to the latest edition of the Ortus Newsletter! This month, we're excited to bring you highlights from our sessions at CFCamp and Open South Code, as well as a sneak peek into our upcoming events. Discover the latest developments in BoxLang, our dynamic new JVM language, and catch up on all the insightful presentations by our expert team. Let's dive in!

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang June 2024 Newsletter!

BoxLang June 2024 Newsletter!

We're thrilled to bring you the latest updates and exciting developments from the world of BoxLang. This month, we're diving into the newest beta release, introducing a new podcast series, showcasing innovative integrations, and sharing insights from recent events. Whether you're a seasoned developer or just getting started, there's something here for everyone to explore and enjoy.

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang 1.0.0 Beta 3 Launched

BoxLang 1.0.0 Beta 3 Launched

We are thrilled to announce the release of BoxLang 1.0.0-Beta 3! This latest beta version is packed with exciting new features and essential bug fixes, including robust encryption functionality, enhanced Java interoperability, and more efficient event handling. Key highlights include the introduction of query caching capabilities, seamless coercion of Java Single Abstract Method (SAM) interfaces from BoxLang functions, and support for virtual thread executors. So, let’s dive into the details of what’s new in BoxLang 1.0.0-Beta 3 and how you can start leveraging these updates today!

Luis Majano
Luis Majano
June 28, 2024