The Ortus BlogBox

"Ortus: A rise, beginning, coming into being, born, the origin!"



Category Filtering: 'testbox'


Using "testbox watch" to Automate Your Testing Suite

Brad Wood
May 19, 2017


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.



CommandBox, TestBox, Tutorials 0

TestBox v2.5.0 Released!

Luis Majano
May 18, 2017


We are excited to announce the release of TestBox version 2.5.0. To install just do:

box install testbox --savedev

To upgrade your current testbox installation just run the following:

box uninstall testbox && install testbox --savedev

TestBox 2.5.0 is a minor release with some great new functionality and tons of fixes. You can find the release notes here and the major updates for this release. One of the biggest features for TestBox that was not part of TestBox, was the addition of TestBox Watchers to CommandBox.

ColdBox MVC, ColdFusion, Community, News, Releases, TestBox 0

Content Box Theme Development: Creating a CI Pipeline

Jon Clausen
Aug 05, 2016


An incredibly powerful feature of ContentBox 3 is the increasing availability of open source themes to jump start your custom development.   For those wishing to contribute back to the community, creating your own theme is as simple as cloning one of our boilerplate themes, creating a new GitHub repo for your customizations, and publishing your theme on Forgebox.  

ContentBox CMS, TestBox, Tutorials 0

Spec Data Binding in TestBox

Luis Majano
May 06, 2016


This issue has comed up several times in our mailing lists, so why not expand a little with a blog post.

The Problem

Many developers working with TestBox love the BDD approach to spec design. Once they get familiar with the syntax they start getting funky! It is just natural! Since they are coding within a CFC they decide to create dynamic it() or specs by iterating over some type of data collection (queries,arrays,structs). The first iteration of the code might look like this:

// Complex Example
for( var filePath in files ){

    it("#getFileFromPath(filePath)# should be valid JSON", function() {

        var json = fileRead(filePath);
        var isItJson = isJSON(json);

        if (isItJson) {
            var data = deserializeJSON(json);
            if (getFileFromPath(filePath) != "index.json") {



The Expectation

Now, you would really expect this to work, and it partially does. What you will see is that only the last binding of the iteration works. This is due to the fact that you are iterating and creating closures at runtime. The problem is that closures rely on its environment when executed, not when defined. So in reality, once TestBox executes these closures for evaluation purposes, the last filePath is the one used, since that is the contents of the variable at the time of the execution of the closure, NOT the definition of the closure.

I know, I know, this is really hurting your brain. That's ok. You are getting funky, doesn't mean it is always easy. Anyways, thankfully, TestBox provides a workaround so you can actually bind the spec with runtime definitions so your closures can actually take the right data.

The Solution

The solutions is to use spec data binding in TestBox. Each closure that defines the it() spec, accepts a data argument which is a structure.

it( title="", data={}, body=function( data ){} );

This is passed by TestBox automatically for you. All you have to do is bind it. You do this by passing another argument to the it() spec called data. This now allows you to update your code to the following:

// Complex Example. Let's iterate over a bunch of files and create dynamic specs
for( var filePath in files ){

    title="#getFileFromPath( filePath )# should be valid JSON", 
    // pass in a struct of data to the spec for later evaluation
    data = { filePath = filePath },
    // the spec closure accepts the data for later evaluation
    function( data ) {
      var json = fileRead( data.filePath );
      var isItJson = isJSON( json );

      expect( json ).notToBeEmpty();
      expect( isItJson ).toBeTrue();

      if( isItJson ){
          var jsonData = deserializeJSON(json);
          if( getFileFromPath( filePath ) != "index.json"){
              expect( jsonData ).toHaveKey( "name" );
              expect( jsonData ).toHaveKey( "type" );



Now you can generate dynamic specs and bind them accordingly at runtime! Enjoy!

TestBox, Tutorials 0

REST2016 - Testing your API with TestBox

Gavin Pickin
Mar 18, 2016


Are you writing APIs? Going to start writing APIs? Now is the time to start testing. Do it early, and often, and reap the benefits as the project grows. TestBox, the defacto CFML test suite, can help your test your API, whether it’s CFML or not.

I will assume you have the basic TextBox installation setup.

ColdBox MVC, REST, RoadShow, TestBox 1

TestBox v2.3.0 Released!

Luis Majano
Mar 11, 2016


Team TestBox is proud to bring our latest release to the masses, v2.3.0.  This release includes a collection of fixes but also several new cool features thanks to Mr Eric Peterson and our Slack community. It has been incredible to get so much community support in this project and so many pull requests and even to our documentation. So thank you so much for supporting and believing in us. This release is for you!

All the docs have been updated in our documentation book and check out the what's new page for an in-depth overview of this release.

You can also very easily get started or update your project with TestBox via CommandBox CLI for ColdFusion (CFML):

ColdBox MVC, ColdFusion, Community, News, Releases, TestBox 0

Build, Test, and Deploy Your Module with Travis CI

Jon Clausen
Feb 15, 2016


In its early stages, shipping your new module isn't such a big deal.  The .zip link provided by GitHub works fine for the Forgebox link, and it's not a big deal to update the entry whenever you release a new version.  Once you release it and other developers actually start using and depending on your software, however, the need to automate aspects of the build and deployment process become apparent.  
ColdBox MVC, CommandBox, ForgeBox, TestBox 3

TestBox v2.2.0 Released!

Luis Majano
Oct 21, 2015


Team TestBox is proud to bring our latest release to fruition, v2.2.0.  This release includes a collection of fixes but also several new cool features like gherkins-like syntax support, spec data binding, test listeners and much more.  We invite you to read our updated documentation book and the what's new page for an in-depth overview of the release.

You can also very easily get started or update your project with TestBox via CommandBox CLI for ColdFusion (CFML):

# install testbox
box install testbox

# update testbox
box update testbox

#what you thought there was more?

Major Features

Below you can find quick updates on our major features for this release.

ColdBox MVC, ColdFusion, Community, News, Releases, TestBox 0

ColdBox 4 Book has arrived

Luis Majano
May 04, 2015


We are excited to finally announce the availability of the ColdBox 4 printed and kindle book. Enjoy!


Books, CacheBox, ColdBox MVC, CommandBox, ContentBox CMS, LogBox, TestBox, TestBox, WireBox 0
1 2 3 4 5 6 >>