Skip to content

Instantly share code, notes, and snippets.

@adamcameron
Last active January 1, 2016 07:19
Show Gist options
  • Save adamcameron/8111064 to your computer and use it in GitHub Desktop.
Save adamcameron/8111064 to your computer and use it in GitHub Desktop.
Demonstrating different between an erroring beforeTests() and an erroring setup()
// Application.cfc
component {
this.mappings = {
"/testbox" = expandPath("/frameworks/testbox/"),
"/mxunit" = expandPath("/frameworks/testbox/system/testing/compat"),
"/unittests" = expandPath("/shared/git/blogExamples/unittests")
};
}
<!--- runTests.cfm --->
<cfoutput>
#createObject("mxunit.runner.DirectoryTestSuite").run(
directory = getDirectoryFromPath(getCurrentTemplatePath()),
componentPath = "unittests.testbox.beforeTests",
recurse = false
).getResultsOutput("simple")#
</cfoutput>
// TestBeforeTests.cfc
component extends="mxunit.framework.TestCase" {
public void function beforeTests(){
throw(type="TestException", message="An error in beforeTests() just errors out");
}
}
//TestSetup.cfc
component extends="mxunit.framework.TestCase" {
public void function setup(){
throw(type="TesTException", message="An error in setup() is handled gracefully");
}
public void function testSetup(){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment