首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WSH脚本单元测试框架

WSH脚本单元测试框架
EN

Stack Overflow用户
提问于 2011-04-08 20:32:09
回答 2查看 1.4K关注 0票数 4

我正在寻找一个单元测试框架的WSH脚本(vbs/wsf,而不是VB6,VBA)。

除了这个项目,我什么也找不到(看起来不错,但上一次活动是两年前的recorder,还没有测试过):

http://code.google.com/p/vbslib/

谢谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-04-08 20:42:23

还有ScriptUnit,如果你只是搜索"vbscript unittest“,你会发现an ancient posting of mine (不是很成功)。我仍然对这个话题感兴趣,并愿意以一种适合您的方式进行合作。

票数 3
EN

Stack Overflow用户

发布于 2016-10-04 08:40:03

我刚刚发布了一个GitHub代码库,其中包含一个超轻量级的基于VBScript的单元测试框架。目前它只有AssertEqual和AssertErrorRaised,但如果有必要的话,添加更多将是非常容易的:https://github.com/koswald/VBScript

下面是一个spec file的代码片段

代码语言:javascript
复制
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

代码语言:javascript
复制
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
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5595067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档