Blog

Luis Majano

October 15, 2013

Spread the word


Share your thoughts

We are so pleased to bring you another addition to our Box collection of products: TestBox.  TestBox is a next generation testing framework for ColdFusion that is based on BDD (Behavior Driven Development) for providing a clean obvious syntax for writing tests. It contains not only a testing framework, runner, assertions and expectations library but also integrates with MockBox for mocking and stubbing. It also supports xUnit style of testing and MXUnit compatibilities.  At this point TestBox has been released as a 1.0.0 Alpha and can be downloaded from our main downloads page and it has been also integrated into our "development" branch for the ColdBox platform as well.  As you will see, TestBox also leverages Closures extensively to provide nice clear syntaxes in your tests.

Features At A Glance

  • Here are a simple listing of features TestBox brings to the table:
  • BDD style testing
  • xUnit style testing
  • Testing life-cycle methods
  • MockBox integration for mocking and stubbing
  • Ability to extend and create custom test runners
  • Ability to extend and create custom test reporters
  • Extensible reporters, bundled with tons of them:
  •     JSON
  •     XML
  •     JUnit 4 XML
  •     Text (80's style)
  •     Console
  •     TAP (Test Anything Protocol)
  •     Simple HTML
  •     Min - Minimalistic Heaven
  •     Raw
  • Asynchronous testing
  • Multi-suite capabilities
  • Test skipping
  • Suite skipping
  • Dynamic skipping support via runtime executions
  • Test one or more suites exclusively
  • Test one or more tests/specs exclusively
  • Test labels and tagging
  • Clickable suite titles to filter test execution
  • Direct MXUnit replacement
  • Much more!

Like with anything we do, it is completely documented in three separate guides:

  1. TestBox Complete Docs
  2. TestBox BDD Primer
  3. TestBox xUnit Primer

Finally, TestBox is also a direct drop-replacement for MXUnit as well.  We have fully documented how you can re-use your tests within TestBox and also migrate them if you need to.  Check out some cool BDD action you will be able to do with TestBox:

describe("Some Included TestBox Matchers:", function() {

     describe("The 'toBe' matcher", function() {
          it("works for simple values", function() {
               coldbox = 1;
               expect( coldbox ).toBe( 1 );
               expect( coldbox ).notToBe( 5 );
          });

          it("works for complex values too (arrays,structs,queries,objects)", function() {
               expect( [1,2] ).toBe( [1,2] );
               expect( { name="luis", awesome=true} ).toBe( { awesome=true, name="luis" } );
               expect( this ).toBe( this );
               expect( queryNew("") ).toBe( queryNew("") );
          });
     });

     it("The 'toBeWithCase' matches strings with case equality", function() {
          expect( 'hello' ).toBeWithCase( 'hello' );
          expect( 'hello' ).notToBeWithCase( 'HELLO' );
     });

     it("The 'toBeTrue' and 'toBeFalse' matchers are used for boolean operations", function() {
          coldbox_rocks = true;
          expect( coldbox_rocks ).toBeTrue();
          expect( !coldbox_rocks ).toBeFalse();
     });

     it("The 'toBeNull' expects null values", function() {
          foo = "bar";
          expect( javaCast("null", "") ).toBeNull();
          expect( foo ).notToBeNull();
     });

     it("The 'toBeInstanceOf' expects the object to be of the same class or inheritance or implementation", function() {
          expect( new coldbox.system.testing.Assertions ).toBeInstanceOf( 'coldbox.system.testing.Assertions' );
          expect( this ).notToBeInstanceOf( 'coldbox.system.testing.MockBox' );
     });

     it("The 'toMatch' matcher is for regular expressions with case sensitivity", function() {
          message = 'foo man choo';

          expect( message ).toMatch( '^foo' );
          expect( message ).toMatch( '(man)' );
          expect( message ).notToMatch( 'superman' );
     });

     it("The 'toMatchNoCase' matcher is for regular expressions with no case sensitivity", function() {
          message = 'foo man choo';

          expect( message ).toMatch( '^FOO' );
          expect( message ).toMatch( '(MAN)' );
          expect( message ).notToMatch( 'SuperMan' );
     });

     describe("The 'toBeTypeOf' matcher evaluates using the CF isValid() function", function() {
          it("works with direct calls", function() {
               expect( [1,2] ).toBeTypeOf( 'Array' );
               expect( { name="luis", awesome=true} ).toBeTypeOf( 'struct' );
               expect( this ).toBeTypeOf( 'component' );
               expect( '03/01/1990' ).toBeTypeOf( 'usdate' );
          });

          it("works with dynamic calls as well", function() {
               expect( [1,2] ).toBeArray();
               expect( { name="luis", awesome=true} ).toBeStruct();
               expect( this ).toBeComponent();
               expect( '03/01/1990' ).toBeUsDate();
          });
     });

     it("The 'toBeEmpty' checks emptyness of simple or complex values", function() {
          expect( [] ).toBeEmpty();
          expect( { name="luis", awesome=true} ).notToBeEmpty();
          expect( '' ).toBeEmpty();
     });

     it("The 'toHaveLength' checks size of simple or complex values", function() {
          expect( [] ).toHaveLength( 0 );
          expect( { name="luis", awesome=true} ).toHaveLength( 2 );
          expect( 'Hello' ).toHaveLength( 5 );
     });

     it("The 'toHaveKey' checks for existence of keys in structs", function() {
          expect( { name="luis", awesome=true} ).toHaveKey( 'name' );
     });

     it("The 'toHaveDeepKey' checks for existence of keys anywhere in structs", function() {
          expect( { name="luis", { age=35, awesome=true } } ).toHaveKey( 'age' );
     });

     it("The 'toThrow' checks if the actual call fails", function() {
          expect( function(){
               new calculator().divide( 40, 0 );
          }).toThrow();

          expect( function(){
               new calculator().divide( 40, 0 );
          }).toThrow( regex="zero" );
     });

});

What's to come

TestBox is being actively developed and we need your feedback in order to do a full release.  We still have some issues pending with MXUnit compatibility, asynchronous testing, NodeJS and GruntJS integration (Tha'ts Right!), and much more.  So subscribe to our mailing list to stay on top of things or this blog's RSS feed.

Add Your Comment

Recent Entries

Into the Box 2025 | Plan Your Trip With Us!

Into the Box 2025 | Plan Your Trip With Us!

Are you ready to join us for Into the Box 2025 from April 30th to May 2nd in Washington, D.C.? Let’s make your trip planning as smooth as possible. Here you’ll find Airfare discounts, Hotel Deals and fun things to do to the the best out of your trip to D.C.

Maria Jose Herrera
Maria Jose Herrera
January 30, 2025
BoxLang YAML Support has landed

BoxLang YAML Support has landed

We’re thrilled to introduce the bx-yaml module for BoxLang!

This powerful new module brings seamless YAML parsing and emitting capabilities to BoxLang. You can now effortlessly serialize BoxLang native types—including structs, queries, arrays, classes, and more—into YAML. The same simplicity applies to deserialization, making it easy to work with YAML data in your BoxLang applications.

Luis Majano
Luis Majano
January 28, 2025
TestBox v6.1.0 Release

TestBox v6.1.0 Release

We’re super excited to announce the release of TestBox 6.1.0! This release introduces native support for BoxLang without the need for a compatibility mode, unlocking new possibilities for developers embracing BoxLang’s dynamic capabilities. Alongside this exciting update, we’ve added valuable features, improved functionality, and resolved key issues to ensure a smoother and more robust testing experience. Dive into the details and see how TestBox 6.1.0 makes your testing even more seamless and efficient!

Luis Majano
Luis Majano
January 28, 2025