我正在寻找WSH脚本(vbs/wsf,而不是VB6,VBA)的单元测试框架。WSH脚本单元测试框架
我无法找到任何东西,除了这个项目(看起来不错,但最后一项活动是大约2年前录音机,还没有测试它尚未):
http://code.google.com/p/vbslib/
谢谢!
我正在寻找WSH脚本(vbs/wsf,而不是VB6,VBA)的单元测试框架。WSH脚本单元测试框架
我无法找到任何东西,除了这个项目(看起来不错,但最后一项活动是大约2年前录音机,还没有测试它尚未):
http://code.google.com/p/vbslib/
谢谢!
还有ScriptUnit,如果你只是谷歌的“VBScript单元测试”,你会发现an ancient posting of mine(不是很成功)。我仍然对这个话题感兴趣,并希望以适合您的方式进行合作。
我刚推了一个GitHub仓库,其中包含一个基于VBScript的超单元测试框架。现在它只有assertEqual便和AssertErrorRaised,但它是超级容易添加更多,如果这甚至是必要的:https://github.com/koswald/VBScript
这里是一个spec file
With CreateObject("includer")
Execute(.read("VBSValidator"))
Execute(.read("TestingFramework"))
End With
Dim val : Set val = New VBSValidator 'Class Under Test
With New TestingFramework
.describe "VBSValidator class"
.it "should return True when IsBoolean is given a True"
.AssertEqual val.IsBoolean(True), True
End With
一个片段,并在这里是一个样本test launcher
Main
Sub Main
With CreateObject("includer")
ExecuteGlobal(.read("VBSTestRunner"))
End With
Dim testRunner : Set testRunner = New VBSTestRunner
With WScript.Arguments
If .Count Then
'if it is desired to run just a single test file, pass it in on the
'command line, using a relative path, relative to the spec folder
testRunner.SetSpecFile .item(0)
End If
End With
'specify the folder containing the tests; path is relative to this script
testRunner.SetSpecFolder "../spec"
'run the tests
testRunner.Run
End Sub
其实我找到了这个帖子,但是错过了X1的URL(失明......)。谢谢! – AmonPL 2011-04-08 13:16:02
几个问题: 1.您是如何设法执行断言的?我有WSH版本5.8,我得到“类未注册”的错误。 2.您是如何将正在测试的vbs文件包含到测试文件中的? (ReadAll,Execute?) – AmonPL 2011-04-08 14:22:52
对不起,我不确定你在说什么。我的单元测试“系统”有点像Perl方法(没有类(必要)),你只需要调用一个比较来得到合适的值。模块“系统”由ReadAll和ExecuteGlobal实现;它需要一个预处理步骤来获得行号和语法糖。 – 2011-04-08 15:04:07