【发布时间】:2018-09-21 14:29:11
【问题描述】:
我有一个 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()
应用程序.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()
【问题讨论】:
-
尝试将映射更改为
C:\testbox\testbox\,或将\testbox\testbox` folder up one level. I think you may have unzipped to one too many folders. Is there asystem` 文件夹的内容移动到第二个testbox文件夹中? -
@Shawn,现在,将其向上移动一个目录并没有帮助。
-
你的 TestBox 文件在
C:\testbox\或C:\testbox\testbox\中吗?还是其他目录?您的映射应指向包含 TestBox 文件的文件夹。 -
@Shawn,我通过执行您提到的提取解决了这个问题,然后创建了一个 runner.cfm 而不是文档中的 runner.cfc。
-
@Shawn,输入答案并获得分数。
标签: unit-testing coldfusion testbox