WSH 脚本单元测试框架

发布于 2024-10-31 08:05:52 字数 1539 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

始终不够 2024-11-07 08:05:52

还有ScriptUnit,如果你只是谷歌搜索“vbscript unittest”,你会发现我的一个古老的帖子(不是很成功)。我对这个话题仍然感兴趣,并且愿意以适合您的方式进行合作。

There also is ScriptUnit and if you just google for "vbscript unittest" you find an ancient posting of mine (not very successful). I'm still interested in the topic and would like to cooperate in a way suitable for you.

薯片软お妹 2024-11-07 08:05:52

我刚刚推送了一个 GitHub 存储库,其中包含一个基于 VBScript 的超轻量单元测试框架。现在它只有 AssertEqual 和 AssertErrorRaished,但如果有必要的话,添加更多内容将非常容易: https:/ /github.com/koswald/VBScript

这是 规范文件

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

这是一个示例测试启动器< /a>

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

I just pushed a GitHub repo that includes an ultra-lightweight VBScript-based unit testing framework. Right now it only has AssertEqual and AssertErrorRaised, but it would be super easy to add more, if that's even necessary: https://github.com/koswald/VBScript

Here is a snippet from a 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

And here is a sample 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文