Libraries.Testing.Test Documentation

This class represents an abstract test on the system. It can either be instantiated and its state altered or it can be subclassed and executed externally, by a tester or otherwise. Inside it contains a series of helper actions for having one or more value checks. By default, if this test receives a check and at least one of these checks fails, the overall test fails on a run.

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

Summary

Actions Summary Table

ActionsDescription
Check(number value, number expected)This action checks whether two number values are equal, using the default threshold value as the difference allowed.
Check(boolean value, boolean expected)This action checks whether two values are equal.
Check(number value, number expected, number difference)This action checks whether two number values are equal, using the default threshold value as the difference allowed.
Check(integer value, number expected)This action checks whether two values are equal.
Check(text value, text expected)This action checks whether two values are equal.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetErrorMessage()Returns an error message from the test.
GetHashCode()This action gets the hash code for an object.
GetMessage()Returns a message from the test.
GetName()Returns the name of the test.
GetThreshold()Returns the default threshold for the comparison of two numbers.
HasThrewError()Returns whether or not this test threw an error while it executed.
IsPassed()This action returns true if the test passed.
Run()This action executes the test.
SetErrorMessage(text error)Sets an error message from the test.
SetMessage(text message)Sets a error message from the test.
SetName(text name)Sets the name of the test
SetPassed(boolean passed)This action tells the test whether or not it passed.
SetThreshold(number threshold)Sets the default threshold for the comparison of two numbers.
SetThrewError(boolean threwError)Sets whether or not this test threw an error while it executed.

Actions Documentation

Check(number value, number expected)

This action checks whether two number values are equal, using the default threshold value as the difference allowed.

Example Code

use Libraries.Testing.Test
        
        Test result
        output result:Check(0.01, 0.02) //false

Parameters

Return

boolean:

Check(boolean value, boolean expected)

This action checks whether two values are equal.

Example Code

use Libraries.Testing.Test
        
        Test result
        output result:Check(true, false) //false

Parameters

Return

boolean:

Check(number value, number expected, number difference)

This action checks whether two number values are equal, using the default threshold value as the difference allowed.

Example Code

use Libraries.Testing.Test
        
        Test result
        output result:Check(0.01, 0.02, 0.01) //true

Parameters

Return

boolean:

Check(integer value, number expected)

This action checks whether two values are equal.

Example Code

use Libraries.Testing.Test
        
        Test result
        output result:Check(1, 2) //false

Parameters

Return

boolean:

Check(text value, text expected)

This action checks whether two values are equal.

Example Code

use Libraries.Testing.Test
        
        Test result
        output result:Check("Hi", "Not Hi") //false

Parameters

Return

boolean:

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.

Example Code

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

Parameters

Return

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

Equals(Libraries.Language.Object object)

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

Example Code

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

Parameters

Return

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

GetErrorMessage()

Returns an error message from the test.

Return

text: the message

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetMessage()

Returns a message from the test.

Return

text: the message

GetName()

Returns the name of the test. Tests do not have a name by default.

Return

text: the name

GetThreshold()

Returns the default threshold for the comparison of two numbers.

Return

number: the threshold, which is equivalent to me:threshold

HasThrewError()

Returns whether or not this test threw an error while it executed.

Return

boolean: true if it threw an error

IsPassed()

This action returns true if the test passed. By default, it returns false. If even a single check call failed, this test fails unless SetPassed is called explicitly.

Return

boolean: true if the test passed.

Run()

This action executes the test. By default, it does nothing.

Example Code

use Libraries.Testing.Tester
        use Libraries.Testing.Test
        
        Tester tests
        
        Test result
        result:SetMessage("This is a failed test.")
        
        tests:Run(result)

SetErrorMessage(text error)

Sets an error message from the test.

Parameters

SetMessage(text message)

Sets a error message from the test.

Parameters

SetName(text name)

Sets the name of the test

Parameters

SetPassed(boolean passed)

This action tells the test whether or not it passed.

Parameters

SetThreshold(number threshold)

Sets the default threshold for the comparison of two numbers.

Parameters

SetThrewError(boolean threwError)

Sets whether or not this test threw an error while it executed.

Parameters