【发布时间】:2011-04-08 12:32:09
【问题描述】:
我正在寻找用于 WSH 脚本(vbs/wsf,而不是 VB6、VBA)的单元测试框架。
除了这个项目我找不到任何东西(看起来不错,但最后一个活动是大约 2 年前的记录器,还没有测试过):
http://code.google.com/p/vbslib/
谢谢!
【问题讨论】:
标签: unit-testing vbscript wsh
我正在寻找用于 WSH 脚本(vbs/wsf,而不是 VB6、VBA)的单元测试框架。
除了这个项目我找不到任何东西(看起来不错,但最后一个活动是大约 2 年前的记录器,还没有测试过):
http://code.google.com/p/vbslib/
谢谢!
【问题讨论】:
标签: unit-testing vbscript wsh
还有ScriptUnit,如果你只是用谷歌搜索“vbscript unittest”,你会发现an ancient posting of mine(不是很成功)。我仍然对该主题感兴趣,并希望以适合您的方式进行合作。
【讨论】:
我刚刚推送了一个 GitHub 存储库,其中包含一个基于 VBScript 的超轻量级单元测试框架。目前它只有 AssertEqual 和 AssertErrorRaised,但如果有必要添加更多内容会非常容易:https://github.com/koswald/VBScript
这是来自spec file的sn-p
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
【讨论】: