Libraries.Testing.Tester Documentation

This class provides us a test platform for running tests on our system. There are two ways to use it. First, if we provide it a Test object, we can call Run, which will execute the test on our system and keep track of whether or not the test passed. Second, if we prefer to run the computation on our own, we can pass a test object through Add, which already stores its pass or fail flag. Depending on the result, if a test passes, the system places it in a list of passed tests. If the test fails, it places it in a list of failed tests. This allows the system to keep a running tally of the total and provide output for the result.

Example Code

use Libraries.Testing.Tester
use Libraries.Testing.Test

Tester tests

Test result
result:SetMessage("This is a failed test.")

tests:Add(result)

Inherits from: Libraries.Language.Object

Actions Documentation

Add(Libraries.Testing.Test test)

This action assumes a test has already been evaluated and adds it to the results for this run of the test suite.

Parameters

Example

use Libraries.Testing.Tester
use Libraries.Testing.Test

Tester tests

Test result
result:SetMessage("This is a failed test.")

tests:Add(result)

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetFailedTestsIterator()

Returns an iterator over the passing tests.

Return

Libraries.Containers.Iterator: an Iterator

Example

use Libraries.Testing.Tester
use Libraries.Testing.Test

Tester tests

Test result
result:SetMessage("This is a failed test.")

Iterator<Test> iterator = tests:GetFailedTestsIterator()
repeat while iterator:HasNext()
    Test value = iterator:Next()
    output value:GetMessage()
end

GetFailingSize()

Returns the number of failing tests.

Return

integer: the number of failing tests.

Example

use Libraries.Testing.Tester
use Libraries.Testing.Test

Tester tests

Test result
result:SetMessage("This is a failed test.")

output tests:GetFailingSize() //1

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetPassedTestsIterator()

Returns an iterator over the passing tests.

Return

Libraries.Containers.Iterator: an Iterator

Example

use Libraries.Testing.Tester
use Libraries.Testing.Test

Tester tests

Test result
result:SetMessage("This is a failed test.")

Iterator<Test> iterator = tests:GetPassedTestsIterator()
repeat while iterator:HasNext()
    Test value = iterator:Next()
    output value:GetMessage()
end

GetPassingSize()

Returns the number of passing tests.

Return

integer: the number of passing tests.

Example

use Libraries.Testing.Tester
use Libraries.Testing.Test

Tester tests

Test result
result:SetMessage("This is a failed test.")

output tests:GetPassingSize() //0

GetSize()

Returns the total number of tests.

Return

integer: the number of total tests.

Example

use Libraries.Testing.Tester
use Libraries.Testing.Test

Tester tests

Test result
result:SetMessage("This is a failed test.")

output tests:GetSize() //1

Run(Libraries.Testing.Test test)

This action executes the test in question and tracks whether or not it passed.

Parameters

Example

use Libraries.Testing.Tester
use Libraries.Testing.Test

Tester tests

Test result
result:SetMessage("This is a failed test.")

tests:Add(result)