Blog

Luis Majano

April 29, 2020

Spread the word


Share your thoughts


We are excited to announce a major version release of TestBox version 4.0.0. To install just use CommandBox: install testbox --saveDev or to update your TestBox installation update testbox. So let's explore this release:

 

What's New With 4.0.0

TestBox 4.0.0 is a major release. It has compatibility changes that you should be aware of and lots of good features!

 

Compatibility

The major compatibility issues are the engine support removals:

  • Lucee 4.5 Support Dropped
  • Adobe ColdFusion 11 Dropped
 

Updating

It is easy to update, just type update testbox and you are done!

 

Major Features

 

TestBox Output Utilities

Sometimes you need to dump something that is in the CFC you are testing or maybe an asynchronous test. The debug() method is only accessible from your test bundle, so getting to the TestBox output utilities is not easy. We have now implemented the testing utilities into the request scope as request.testbox

This utility struct provides you with the following methods:

MethodComment
console()Send output to the console
debug()Send output to the TestBox reporter debugger
clearDebugBuffer()Clear the debugger
print()Send output to the ColdFusion output buffer
printLn()Same as print() but adding a <br> separator

This way in your code you can add them for better debugging, especially when testing async code:

request.testbox.console( "I am here" )
request.testbox.debug( "why is this not running" )
 

Mocking Data

We have included MockDataCFC as a dependency to TestBox 4. This will allow you to mock not only objects but data as well. You can access the mocking method via the new mockData() method in all your specs. This feature is a life-saver when mocking APIs or data within your applications.

# Array of objects
var data = mockData(
    $num = 3,
    "author" = "name",
    "id" = "uuid"
);

# An object
var data = mockData(
    $returnType = "struct",
    "author" = "name",
    "id" = "uuid"
);

Let's imagine the following object graph:

Author
    Has Many Books
        Has Many Categories
    Has Keywords
    Has A Publisher

I can then use this mocking DSL to define it:

mockData(
    fullName    = "name",
    description = "sentence",
    age         = "age",
    id          = "uuid",
    createdDate = "datetime",
    isActive	= "oneof:true:  false",

    // one to many complex object definitions
    books = [
        {
            $num = "rand:1:         3",
            "id" = "uuid",
            "title" = "words:1:         5",
            "categories" = {
                "$num"      = "2",
                "id"        = "uuid",
                "category"  = "words"
            }
        }
    ],

    // object definition
    publisher = {
        "id" 	= "uuid",
        "name" 	= "sentence"
    },

    // array of values
    keywords = [
        {
            "$num" 	= "rand:1:         10",
            "$type" = "words"
        }
    ]
);

More information here: https://www.forgebox.io/view/mockdatacfc

 

Release Notes

 

Bugs

  • [TESTBOX-275] - Exception in beforeTests/afterTests not reported in a meaningful way on the ANT Junit Reporter
  • [TESTBOX-278] - Fix the coverage % in HTML visualizer
 

New Features

  • [TESTBOX-274] - New testbox output utilities struct: request.testbox
  • [TESTBOX-276] - MockdataCFC is now a first class module in TestBox
  • [TESTBOX-277] - New mockData() method in your base specs so you can mock any type of data
  • [TESTBOX-280] - Add cfconfig.json for controlling output and consistency between testing in diff engines
 

Tasks

Add Your Comment

Recent Entries

BoxLang 1.0.0 Beta 7 Launched

BoxLang 1.0.0 Beta 7 Launched

We are pleased to announce the release of BoxLang 1.0.0-Beta 7! This latest beta version includes improvements and essential bug fixes, but more importantly it certifies the execution of ColdBox HMVC and TestBox.

What is BoxLang?

BoxLang is a modern dynamic JVM language that can be deployed on multiple runtimes: operating system (Windows/Mac/*nix/Embedded), web server, lambda, iOS, android, web assembly, and more. BoxLang combines many features from different progr

Luis Majano
Luis Majano
July 26, 2024
New BoxLang Feature: Java Method References and Higher-Order Functions

New BoxLang Feature: Java Method References and Higher-Order Functions

We’ve added more goodies to our BoxLang Java interop: method references and higher-order functions. CFML has never let you do these things, making Java Interop feel like a second-class citizen. But with BoxLang, we’re elevating Java integration to a new level.

Maria Jose Herrera
Maria Jose Herrera
July 26, 2024
Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Are you a CFML developer looking to take your skills to the next level? Look no further than the ColdBox from Zero to Hero Virtual Live Training! This intensive two-day course will equip you with the knowledge and expertise to build robust and scalable applications using ColdBox 7, the latest version of the most popular CFML MVC framework.

What You'll Learn:

  • Master the Fun...

Cristobal Escobar
Cristobal Escobar
July 24, 2024