我有一个Coldfusion应用程序,我想开始为其编写单元测试。我找到了testbox,并认为它将是一个很棒的测试库。我遵循了installation instructions,但是当我尝试运行我的第一个测试时,我的冷聚变应用程序抛出错误。
我下载了zip文件,并将其放入C驱动器,并将映射添加到application.cfc,但是它引发以下错误(请参见下文)。谁能帮我调试为什么找不到文本框?

错误

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()


测试盒目录。
unit-testing - Coldfusion-找不到文本框-LMLPHP

最佳答案

尝试将映射更改为C:\testbox\testbox\,或将\testbox\testbox文件夹的内容上移一级。我认为您可能已解压缩到一个文件夹太多。第二个system文件夹中是否有一个testbox文件夹?您要确保映射指向包含实际TestBox文件的文件夹。

09-27 13:51