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
有一個模板視圖,其來源位於測試資料夾中。