我正在寻找一个单元测试框架的WSH脚本(vbs/wsf,而不是VB6,VBA)。
除了这个项目,我什么也找不到(看起来不错,但上一次活动是两年前的recorder,还没有测试过):
http://code.google.com/p/vbslib/
谢谢!
发布于 2011-04-08 20:42:23
还有ScriptUnit,如果你只是搜索"vbscript unittest“,你会发现an ancient posting of mine (不是很成功)。我仍然对这个话题感兴趣,并愿意以一种适合您的方式进行合作。
发布于 2016-10-04 08:40:03
我刚刚发布了一个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 Subhttps://stackoverflow.com/questions/5595067
复制相似问题