classicAspUnit
1.0.0
一个经典的 ASP 单元框架,用于帮助测试经典的 ASP 代码。
实例化上下文:
set testContext = new aspUnit
创建一个测试用例:
set oTest = testContext.addTestCase("User Administration")
做出断言:
oTestMethod.AssertExists usersDB, "optional message override: {1}" ' accepts a wildcard marks for the parammeters oTestMethod.AssertIsA usersDB, "testDB", "" ' leave blank for default message
您还可以创建要在Test Case
的每次测试之前和之后执行的测试设置和拆卸:
sub testSetup() set usersDB = new testDB usersDB.TableName = "users" set newUser = new User newUser.id = 1 newUser.name = "Bob" usersDB.add newUser end sub sub testTeardown() set usersDB = nothing end sub
...然后传递测试用例的方法名称:
oTest.Setup("testSetup") oTest.Teardown("testTeardown")
这也可以工作:
oTest.Setup("myGlobalObject.MyMethod(1, ""param2"", true)")
警告:这使用
Execute
来运行代码,并将接受任何可执行代码字符串,例如"myVar = 1"
或"myFunction() : myOtherFunction()"
运行并获取测试结果:
set results = testContext.run results.Update ' This will update the test counters for passed, failed and errors
然后您可以访问结果并编写您想要的任何视图:
Response.Write "Test Cases: " & results.TestCases.Count & "
" Response.Write "Tests runned: " & results.Tests & ", " Response.Write "Tests passed: " & results.Passed & ", " Response.Write "Tests failed: " & results.Failed & ", " Response.Write "Tests errored: " & results.Errors & "
" ' loop the testCases for each testCase in result.TestCases.Items Response.Write "-> Test Case: " & testCase.Name & "(" & testCase.Status & ")
" ' loop the tests for each test in testCase.Tests.Items Response.Write "--> Test: " & test.Name & "
" Response.Write "----> " & test.Output & "(" & test.Status & ")
" next next
有一个模板视图,其源位于测试文件夹中。