Coder Social home page Coder Social logo

classicaspunit's Introduction

Classic ASPUnit

A classic ASP unit framework for helping in testing classic asp code.

Usage

Instantiate the context:

set testContext = new aspUnit

Create a test case:

set oTest = testContext.addTestCase("User Administration")

Make assertions:

oTestMethod.AssertExists usersDB, "optional message override: {1}" ' accepts a wildcard marks for the parammeters
oTestMethod.AssertIsA usersDB, "testDB", "" ' leave blank for default message

You can also create test setups and teardowns to be executed before and after each test for a 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

... and then pass the method names for the Test Case:

oTest.Setup("testSetup")
oTest.Teardown("testTeardown")

This would work too:

oTest.Setup("myGlobalObject.MyMethod(1, ""param2"", true)")

Warning: This uses Execute to run the code and will accpect any executable code string like "myVar = 1" or "myFunction() : myOtherFunction()"

To run and get the results of the tests:

set results = testContext.run
results.Update ' This will update the test counters for passed, failed and errors

Then you can have access to the results and write any view you want:

Response.Write "Test Cases: " & results.TestCases.Count & "<br>"
Response.Write "Tests runned: " & results.Tests & ", "
Response.Write "Tests passed: " & results.Passed & ", "
Response.Write "Tests failed: " & results.Failed & ", "
Response.Write "Tests errored: " & results.Errors & "<br><br>"

' loop the testCases
for each testCase in result.TestCases.Items
	Response.Write "-> Test Case: " & testCase.Name & "(" & testCase.Status & ")<br>"
	
	' loop the tests
	for each test in testCase.Tests.Items
		Response.Write "--> Test: " & test.Name & "<br>"
		Response.Write "----> " & test.Output & "(" & test.Status & ")<br>"
	next
next

There is a template view with the source in the test folder.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.