3

I have a coldfusion application that i would like to start writing unit tests for. I found testbox, and think it would be a great testing library to use. I followed the installation instructions, but my cold fusion app is throwing an error when i try to run my first test. I downloaded the zip file and put in in my C drive, added the mapping to my application.cfc, but it throws the following error (see below). Can anyone help me debug why it can't find textbox?

Error

Invalid CFML construct found on line 2 at column 1.
ColdFusion was looking at the following text:
testbox


The error occurred in C:/inetpub/wwwroot/tests/main.cfc: line 2
1 : // Create TestBox object
2 : testbox = new testbox.system.TestBox();
3 : ​
4 : // You can add fluent specs via addDirectory(), addDirectories(), addBundles()

Application.cfc

component {
    this.name = "A TestBox Runner Suite " & hash( getCurrentTemplatePath() );
    // any other application.cfc stuff goes below:
    this.sessionManagement = true;

    // any mappings go here, we create one that points to the root called test.
    this.mappings[ "/tests" ] = getDirectoryFromPath( getCurrentTemplatePath() );
    // Map back to its root
    this.mappings[ "/testbox" ] = expandPath( "C:/testbox/" );

    // any orm definitions go here.

    // request start
    public boolean function onRequestStart( String targetPage ){
        return true;
    }
}

main.cfc

// Create TestBox object
testbox = new testbox.system.TestBox();
​
// You can add fluent specs via addDirectory(), addDirectories(), addBundles()
testbox.addDirectory( "specs" );
​
// Run tests and produce reporter results
testbox.run()
​
// Run tests and get raw testbox.system.TestResults object
testbox.runRaw()
​
// Run tests and produce reporter results from SOAP, REST, HTTP
testbox.runRemote()

test box directory. enter image description here

AJ_
  • 3,787
  • 10
  • 47
  • 82
  • Try changing your mapping to `C:\testbox\testbox\ `, or move the contents of your `\testbox\testbox\` folder up one level. I think you may have unzipped to one too many folders. Is there a `system` folder inside the second `testbox` folder? – Shawn Sep 21 '18 at 15:04
  • @Shawn, now, moving it up a directory did not help. – AJ_ Oct 16 '18 at 19:20
  • Are your TestBox files in `C:\testbox\ ` or `C:\testbox\testbox\ `? Or some other directory? Your mapping should point to the folder that contains the TestBox files. – Shawn Oct 16 '18 at 19:30
  • @Shawn, i resolved the issue by doing the extraction you mentioned, and then creating a runner.cfm instead of a runner.cfc like in the docs. – AJ_ Oct 16 '18 at 19:40
  • @Shawn, put in an answer and get some points. – AJ_ Oct 16 '18 at 19:40

1 Answers1

1

Try changing your mapping to C:\testbox\testbox\ , or move the contents of your \testbox\testbox folder up one level. I think you may have unzipped to one too many folders. Is there a system folder inside the second testbox folder? You want to make sure that your mapping points to the folder containing your actual TestBox files.

Shawn
  • 4,758
  • 1
  • 20
  • 29