开发者

WSH scripts unit testing framework [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
开发者_StackOverflow中文版

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 6 years ago.

Improve this question

I'm looking for a unit testing framework for WSH scripts (vbs/wsf, not VB6, VBA).

I can't find anything except this project (looks good, but last activity was recorder around 2 years ago, haven't tested it yet):

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

Thanks!


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜