ITB2021: Keynote

TestBox, DocBox, and CBORM

TestBox 4.x

  • Began TestBox 4.x series last April
  • 5+ releases

Output Utilities

Add debug output via `request.testbox`

request.testbox.debug(
  variables.ormUtil.getHibernateVersion()
);

Output Utilities

Send debug info to the console

request.testbox.console(
  "Reached point XYZ"
);

// in a spec:
console( "Reached point X!" );

Output Utilities

Clear debug output buffer

request.testbox.clearDebugBuffer();

// in your spec:
clearDebugBuffer();

Output Utilities

Print to the ColdFusion output buffer

request.testbox.print( "line of text" );

// in your spec:
print( "debug me please" );

Output Utilities

Print to the ColdFusion output buffer
-- now with line breaks!

request.testbox.printLn( "line of text" );

// in your spec:
printLn( "debug me please" );

MockData

Ray Camden's MockDataCFC is now in TestBox core

# Array of objects
var data = mockData(
    $num = 3,
    "author" = "name",
    "id" = "uuid"
);
[
    {
        author: "Frank Smith",
        id: e3ed98ed-8103-440e-bcb6-52f97f400bd9
    },
    {
        author: "Gary Stroz",
        id: bdf130c3-c1e4-4b7e-b35e-128d376600e6
    },
    {
        author: "Lynn Padgett",
        id: b8681971-747f-4501-a059-3be433021ee9
    }
]

Improved Text Reporters

  • text reporter
  • mintext reporter
box testbox run reporter=mintext

IDE Integration

Clicking a filename in a stacktrace or "Failure Origin" will open the file in your favorite editor.

So Much More!

  • Bug fixes
  • Enhancements coming out the ears

What's Next?

  • Dry Run : Ability to retrieve tests to execute

  • New Testing UI Experience

  • VSCode Testing Integration

  • JMESPath JSON Structure Expectations

  • TestBox Feature Definitions via YAML

  • Native Gherkins Support

DocBox 3

  • Had not received love in quite some time
  • What is DocBox, Why DocBox?

Strategy Aliases

Configure documentation via "alias" short names

variables.docbox = new docbox.DocBox(
	strategy   = "docbox.strategy.api.HTMLAPIStrategy",
	properties = {
		projectTitle : "DocBox Tests",
		outputDir    : variables.testOutputDir
	}
);
variables.docbox = new docbox.DocBox(
	strategy   = "HTML",
	properties = {
		projectTitle : "DocBox Tests",
		outputDir    : variables.testOutputDir
	}
);

New JSON strategy

  • Machine-readable documentation
  • Great for documentation viewers
  • Two file formats:
    • overview-summary.json
    • package/myClass.json
docbox = new docbox.DocBox( "JSON", {
    outputDir   : expandPath( "resources/assets/docs" ),
    projectTitle: "Vehicles API"
});

Multi-Format Output

  • Generate documentation in multiple formats simultaneously
  • New .addStrategy() method
docbox.DocBox()
	.addStrategy(
		"HTML",
		{ outputDir : variables.HTMLOutputDir }
	)
	.addStrategy(
		"UML",
		{ outputFile : variables.XMIOutputFile }
	)
	.generate(
		source   = expandPath( "/models" ),
		mapping  = "tests",
		excludes = "(coldbox|build\-docbox)"
	);

New DocBox OrtusBook

CBORM

  • Very active year for CBORM
  • 6 new releases in the last 12 months
  • Lots of new features!

Lucee Hibernate 5.4 Extension

  • Partnered with LAS to upgrade Hibernate extension to 5.4
    • Added support for additional Hibernate events
    • Changed syntax for positional parameters
    • Moves embedded Hibernate forward a decade 😀

Lucee Hibernate 5.4 Extension

New Hibernate event support

  • onDirtyCheck
  • onEvict
  • onClear
  • onFlush
  • onAutoFlush

Lucee Hibernate 5.4 Extension

New CBORM interception points

  • ORMDirtyCheck
  • ORMEvict
  • ORMClear
  • ORMFlush
  • ORMAutoFlush

Lucee Hibernate 5.4 Extension

component {
  property name="log" inject="logbox:logger:this";

  function ORMEvict( struct interceptData ){
      if( log.canDebug() ){
        log.debug( "Entity evicted:", interceptData.entity );
      }
  }
}

Positional Parameter Syntax

  • Changed in Hibernate 5.3
  • JDBC syntax deprecated and dropped
  • JPA syntax is "in"

Positional Parameter Syntax

var params = [
  createUUID(),
  "Michael",
  "Born"
];

ORMExecuteQuery( "INSERT INTO users ( ?, ?, ? )", params );

JDBC-style parameters:

No longer supported in Hibernate 5.3+

Positional Parameter Syntax

var params = [
  createUUID(),
  "Michael",
  "Born"
];

ORMExecuteQuery( "INSERT INTO users ( ?1, ?2, ?3 )", params );

Use JPA-style (numbered) parameters instead:

New isInTransaction() helper

var util = getInstance( "ORMUtilSupport@cborm" );

myNewEntity.save( transactional = !util.isInTransaction() );

Easily avoid nesting transactions if the executing code is already in a transaction.

New getHibernateVersion() helper

var util = getInstance( "ORMUtilSupport@cborm" );

if ( left( util.getHibernateVersion(), 3 ) < 4.0 ){
  // Hibernate 3 implementation
} else {
  // Hibernate 4+ implementation
}

Toggle implementations for newer/older Hibernate versions

ITB2021: Keynote

By Michael Born

ITB2021: Keynote

  • 450