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

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.

Parameters

  • number value
  • number expected

Return

boolean:

Example

use Libraries.Testing.Test

Test result
output result:Check(0.01, 0.02) //false

Check(boolean value, boolean expected)

This action checks whether two values are equal.

Parameters

  • boolean value
  • boolean expected

Return

boolean:

Example

use Libraries.Testing.Test

Test result
output result:Check(true, false) //false

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.

Parameters

  • number value
  • number expected
  • number difference

Return

boolean:

Example

use Libraries.Testing.Test

Test result
output result:Check(0.01, 0.02, 0.01) //true

Check(integer value, number expected)

This action checks whether two values are equal.

Parameters

  • integer value
  • number expected

Return

boolean:

Example

use Libraries.Testing.Test

Test result
output result:Check(1, 2) //false

Check(text value, text expected)

This action checks whether two values are equal.

Parameters

  • text value
  • text expected

Return

boolean:

Example

use Libraries.Testing.Test

Test result
output result:Check("Hi", "Not Hi") //false

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)

GetErrorMessage()

Returns an error message from the test.

Return

text: the message

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()

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

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

  • text error: the message

SetMessage(text message)

Sets a error message from the test.

Parameters

  • text message

SetName(text name)

Sets the name of the test

Parameters

  • text name: the name of the test

SetPassed(boolean passed)

This action tells the test whether or not it passed.

Parameters

  • boolean passed: tells the test to indicate that it passed

SetThreshold(number threshold)

Sets the default threshold for the comparison of two numbers.

Parameters

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

SetThrewError(boolean threwError)

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

Parameters

  • boolean threwError: Sets whether this test through an error