Qore jni Module  1.0.1
org.qore.lang.qunit.Test Class Reference

Base class (wrapping the Qore QUnit::Test class) representing a simple test, implements an implicit main() method and all utility methods for testing. More...

Inheritance diagram for org.qore.lang.qunit.Test:
org.qore.jni.QoreObjectWrapper

Public Member Methods

 Test (String name, String version) throws Throwable
 creates the object and sets the name of the test
 
void globalSetUp () throws Throwable
 global setup; will be called once before tests are run
 
void globalTearDown () throws Throwable
 global tear down; will be called once after all tests are run
 
void setUp () throws Throwable
 Prototype method for setting up test environment. It will be called for each test individually.
 
void tearDown () throws Throwable
 Prototype method for cleaning up test environemnt. It will be called after each test has executed.
 
String getEnv (String key, String def) throws Throwable
 facade for the system environment variables
 
void addTestCase (String name, TestCode call) throws Throwable
 adds a test case to run More...
 
void addTestCase (String name, TestCodeArgs call, Object... args) throws Throwable
 adds a test case to run More...
 
Object testAssertionValue (String name, Object actual, Object expected) throws Throwable
 Tests a value for equality to an expected value. More...
 
Object testAssertionValue (String name, BigDecimal actual, BigDecimal expected, BigDecimal epsilon) throws Throwable
 Tests a value for equality to an expected value of number type. More...
 
Object testAssertionValue (String name, BigDecimal actual, BigDecimal expected) throws Throwable
 Tests a value for equality to an expected value of number type. More...
 
Object testAssertionValue (String name, float actual, float expected, float epsilon) throws Throwable
 Tests a value for equality to an expected value of float type. More...
 
Object testAssertionValue (String name, float actual, float expected) throws Throwable
 Tests a value for equality to an expected value of float type. More...
 
void assertRegex (String regex_pattern, String actual, String name) throws Throwable
 Tests that a test value passes a regular expression match. More...
 
void assertRegex (String regex_pattern, String actual) throws Throwable
 Tests that a test value passes a regular expression match. More...
 
void assertNRegex (String regex_pattern, String actual, String name) throws Throwable
 Tests that a test value does not pass a regular expression match. More...
 
void assertNothing (Object actual, String name) throws Throwable
 Tests for no value. More...
 
void assertNothing (Object actual) throws Throwable
 Tests for no value. More...
 
void assertEqSoft (Object expected, Object actual, String name) throws Throwable
 Tests a value for equality to an expected value with soft comparisons (types may differ) More...
 
void assertEqSoft (Object expected, Object actual) throws Throwable
 Tests a value for equality to an expected value with soft comparisons (types may differ) More...
 
void assertNeqSoft (Object expected, Object actual, String name) throws Throwable
 Tests a value for inequality to an expected value with soft comparisons (types may differ) More...
 
void assertNeqSoft (Object expected, Object actual) throws Throwable
 Tests a value for inequality to an expected value with soft comparisons (types may differ) More...
 
void assertEq (Object expected, Object actual, String name) throws Throwable
 Tests a value for equality to an expected value with hard comparisons (types and values must be identical) More...
 
void assertEq (Object expected, Object actual) throws Throwable
 Tests a value for equality to an expected value with hard comparisons (types and values must be identical) More...
 
void assertNeq (Object expected, Object actual, String name) throws Throwable
 Tests a value for inequality to an expected value with hard comparisons (types and values must be identical) More...
 
void assertNeq (Object expected, Object actual) throws Throwable
 Tests a value for inequality to an expected value with hard comparisons (types and values must be identical) More...
 
void assertFloatEq (float expected, float actual, float epsilon, String name) throws Throwable
 Tests a float value for equality to an expected value with an allowed error. More...
 
void assertFloatEq (float expected, float actual, float epsilon) throws Throwable
 Tests a float value for equality to an expected value with an allowed error. More...
 
void assertFloatEq (float expected, float actual) throws Throwable
 Tests a float value for equality to an expected value with an allowed error. More...
 
void assertNumberEq (BigDecimal expected, BigDecimal actual, BigDecimal epsilon, String name) throws Throwable
 Tests a number value for equality to an expected value with an allowed error. More...
 
void assertNumberEq (BigDecimal expected, BigDecimal actual, BigDecimal epsilon) throws Throwable
 Tests a number value for equality to an expected value with an allowed error. More...
 
void assertNumberEq (BigDecimal expected, BigDecimal actual) throws Throwable
 Tests a number value for equality to an expected value with an allowed error. More...
 
void assertGtSoft (Object expected, Object actual, String name) throws Throwable
 Tests that a value is greater than an expected value with soft comparisons (types may differ) More...
 
void assertGtSoft (Object expected, Object actual) throws Throwable
 Tests that a value is greater than an expected value with soft comparisons (types may differ) More...
 
void assertGt (Object expected, Object actual, String name) throws Throwable
 Tests that a value is greater than an expected value with hard comparisons (types may not differ) More...
 
void assertGt (Object expected, Object actual) throws Throwable
 Tests that a value is greater than an expected value with hard comparisons (types may not differ) More...
 
void assertGeSoft (Object expected, Object actual, String name) throws Throwable
 Tests that a value is greater than or equal to than an expected value with soft comparisons (types may differ) More...
 
void assertGeSoft (Object expected, Object actual) throws Throwable
 Tests that a value is greater than or equal to than an expected value with soft comparisons (types may differ) More...
 
void assertGe (Object expected, Object actual, String name) throws Throwable
 Tests that a value is greater than or equal to an expected value with hard comparisons (types may not differ) More...
 
void assertGe (Object expected, Object actual) throws Throwable
 Tests that a value is greater than or equal to an expected value with hard comparisons (types may not differ) More...
 
void assertLtSoft (Object expected, Object actual, String name) throws Throwable
 Tests that a value is less than an expected value with soft comparisons (types may differ) More...
 
void assertLtSoft (Object expected, Object actual) throws Throwable
 Tests that a value is less than an expected value with soft comparisons (types may differ) More...
 
void assertLt (Object expected, Object actual, String name) throws Throwable
 Tests that a value is less than an expected value with hard comparisons (types may not differ) More...
 
void assertLt (Object expected, Object actual) throws Throwable
 Tests that a value is less than an expected value with hard comparisons (types may not differ) More...
 
void assertLeSoft (Object expected, Object actual, String name) throws Throwable
 Tests that a value is less than or equal to than an expected value with soft comparisons (types may differ) More...
 
void assertLeSoft (Object expected, Object actual) throws Throwable
 Tests that a value is less than or equal to than an expected value with soft comparisons (types may differ) More...
 
void assertLe (Object expected, Object actual, String name) throws Throwable
 Tests that a value is less than or equal to an expected value with hard comparisons (types may not differ) More...
 
void assertLe (Object expected, Object actual) throws Throwable
 Tests that a value is less than or equal to an expected value with hard comparisons (types may not differ) More...
 
void assertTrue (Object actual, String name) throws Throwable
 Tests a boolean value. More...
 
void assertTrue (Object actual) throws Throwable
 Tests a boolean value. More...
 
void assertFalse (Object actual, String name) throws Throwable
 Tests a boolean value. More...
 
void assertFalse (Object actual) throws Throwable
 Tests a boolean value. More...
 
void assertThrows (String expectedErr, String expectedDesc, TestCodeArgs theCode, Object[] args, String name) throws Throwable
 Tests that a piece of code throws an exception with given description. More...
 
void assertThrows (String expectedErr, String expectedDesc, TestCodeArgs theCode, Object[] args) throws Throwable
 Tests that a piece of code throws an exception with given description. More...
 
void assertThrows (String expectedErr, String expectedDesc, TestCodeArgs theCode) throws Throwable
 Tests that a piece of code throws an exception with given description. More...
 
void assertThrows (String expectedErr, TestCodeArgs theCode, Object[] args, String name) throws Throwable
 Tests that a piece of code throws an exception with given description. More...
 
void assertThrows (String expectedErr, TestCodeArgs theCode, Object[] args) throws Throwable
 Tests that a piece of code throws an exception with given description. More...
 
void assertThrows (String expectedErr, String expectedDesc, TestCode theCode, String name) throws Throwable
 Tests that a piece of code throws an exception with given description. More...
 
void assertThrows (String expectedErr, String expectedDesc, TestCode theCode) throws Throwable
 Tests that a piece of code throws an exception with given description. More...
 
void assertThrows (String expectedErr, TestCode theCode, String name) throws Throwable
 Tests that a piece of code throws an exception with given description. More...
 
void assertThrows (String expectedErr, TestCode theCode) throws Throwable
 Tests that a piece of code throws an exception with given description. More...
 
void assertSkip (String name) throws Throwable
 Skips assertion on purpose. More...
 
void fail (String msg) throws Throwable
 Fails the test unconditionally. More...
 
void testNullAssertion (String name, TestConditionArgs condition, Object... args) throws Throwable
 Tests for a single assertion for a call returning no value (for example, to ensure that the call does not throw an exception) More...
 
Object testAssertion (String name, TestConditionArgs condition, Object[] args, Object expectedResultValue) throws Throwable
 Tests for a single assertion for a call returning an integer value and returns the value generated. More...
 
void testNullAssertion (String name, TestCondition condition) throws Throwable
 Tests for a single assertion for a call returning no value (for example, to ensure that the call does not throw an exception) More...
 
Object testAssertion (String name, TestCondition condition, Object expectedResultValue) throws Throwable
 Tests for a single assertion for a call returning an integer value and returns the value generated. More...
 
Object testAssertion (String name, TestConditionArgs condition, Object[] args, AbstractTestResult expectedResult) throws Throwable
 Tests for a single assertion and returns the value generated. More...
 
Object testAssertion (String name, TestConditionArgs condition, Object[] args) throws Throwable
 Tests for a single assertion and returns the value generated. More...
 
Object testAssertion (String name, TestCondition condition, AbstractTestResult expectedResult) throws Throwable
 Tests for a single assertion and returns the value generated. More...
 
Object testAssertion (String name, TestCondition condition) throws Throwable
 Tests for a single assertion and returns the value generated. More...
 
void testSkip (String reason, Object... args) throws Throwable
 Skips a given test, eg. because it may be missing some dependencies. More...
 
void testSkip (String reason) throws Throwable
 Skips a given test, eg. because it may be missing some dependencies. More...
 
boolean equals (Object a, Object b) throws Throwable
 Compare two values for equality. More...
 
boolean notEquals (Object a, Object b) throws Throwable
 Compare two values for inequality. More...
 
boolean regexpMatches (String s, String regexp) throws Throwable
 Compare a string for match against a regexp. More...
 
int main () throws Throwable
 Run the whole suite, report results.
 
- Public Member Methods inherited from org.qore.jni.QoreObjectWrapper
 QoreObjectWrapper (QoreObject obj)
 creates the wrapper object with the Qore object
 
void release ()
 releases the Qore object; do not call any further methods on the object after this call
 
QoreObject getQoreObject ()
 returns the Qore object
 
String className ()
 returns the class name for the Qore object
 
boolean instanceOf (String class_name)
 returns true if the object is an instance of the given class
 

Static Public Member Methods

static String getAssertionName (String name) throws Throwable
 returns the assertion name for display purposes
 
static String getAssertionName () throws Throwable
 returns the assertion name for display purposes
 

Private Member Methods

 Test (QoreObject obj) throws Throwable
 creates the object based on the given Qore object
 

Additional Inherited Members

- Private Attributes inherited from org.qore.jni.QoreObjectWrapper
QoreObject obj
 the wrapper Qore object
 

Detailed Description

Base class (wrapping the Qore QUnit::Test class) representing a simple test, implements an implicit main() method and all utility methods for testing.

Note
Loads and initializes the Qore library and the jni module in static initialization if necessary

Member Function Documentation

◆ addTestCase() [1/2]

void org.qore.lang.qunit.Test.addTestCase ( String  name,
TestCode  call 
) throws Throwable
inline

adds a test case to run

Example:
addTestCase("MyTest", \myTest());
Parameters
namethe name of the test case
callthe code to call that executes the test case

◆ addTestCase() [2/2]

void org.qore.lang.qunit.Test.addTestCase ( String  name,
TestCodeArgs  call,
Object...  args 
) throws Throwable
inline

adds a test case to run

Example:
addTestCase("MyTest", \myTest());
Parameters
namethe name of the test case
callthe code to call that executes the test case
argsany optional arguments to the test case call

◆ assertEq() [1/2]

void org.qore.lang.qunit.Test.assertEq ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests a value for equality to an expected value with hard comparisons (types and values must be identical)

Example:
assertEq(5, method_that_should_return_five());
Parameters
expectedthe expected value
actualthe value generated by the test
namethe name or description of the assertion

◆ assertEq() [2/2]

void org.qore.lang.qunit.Test.assertEq ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests a value for equality to an expected value with hard comparisons (types and values must be identical)

Example:
assertEq(5, method_that_should_return_five());
Parameters
expectedthe expected value
actualthe value generated by the test

◆ assertEqSoft() [1/2]

void org.qore.lang.qunit.Test.assertEqSoft ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests a value for equality to an expected value with soft comparisons (types may differ)

Example:
assertEqSoft("5", method_that_should_return_five());
Parameters
expectedthe expected value
actualthe value generated by the test
namethe name or description of the assertion

◆ assertEqSoft() [2/2]

void org.qore.lang.qunit.Test.assertEqSoft ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests a value for equality to an expected value with soft comparisons (types may differ)

Example:
assertEqSoft("5", method_that_should_return_five());
Parameters
expectedthe expected value
actualthe value generated by the test

◆ assertFalse() [1/2]

void org.qore.lang.qunit.Test.assertFalse ( Object  actual,
String  name 
) throws Throwable
inline

Tests a boolean value.

Example:
assertFalse(methodThatShouldReturnFalse());
Parameters
actualthe value generated by the test
namethe name or description of the assertion

◆ assertFalse() [2/2]

void org.qore.lang.qunit.Test.assertFalse ( Object  actual) throws Throwable
inline

Tests a boolean value.

Example:
assertFalse(methodThatShouldReturnFalse());
Parameters
actualthe value generated by the test

◆ assertFloatEq() [1/3]

void org.qore.lang.qunit.Test.assertFloatEq ( float  expected,
float  actual,
float  epsilon,
String  name 
) throws Throwable
inline

Tests a float value for equality to an expected value with an allowed error.

Example:
assertFloatEq(2.5, 2.50001, 0.001);
Parameters
expectedthe expected value
actualthe value generated by the test
epsilonthe allowed error
namethe name or description of the assertion

◆ assertFloatEq() [2/3]

void org.qore.lang.qunit.Test.assertFloatEq ( float  expected,
float  actual,
float  epsilon 
) throws Throwable
inline

Tests a float value for equality to an expected value with an allowed error.

Example:
assertFloatEq(2.5, 2.50001, 0.001);
Parameters
expectedthe expected value
actualthe value generated by the test
epsilonthe allowed error

◆ assertFloatEq() [3/3]

void org.qore.lang.qunit.Test.assertFloatEq ( float  expected,
float  actual 
) throws Throwable
inline

Tests a float value for equality to an expected value with an allowed error.

Example:
assertFloatEq(2.5, 2.50001);
Parameters
expectedthe expected value
actualthe value generated by the test

◆ assertGe() [1/2]

void org.qore.lang.qunit.Test.assertGe ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests that a value is greater than or equal to an expected value with hard comparisons (types may not differ)

Example:
assertGe(5, method_that_should_rturn_a_value_greater_than_or_equal_to_five());
Parameters
expecteda value that should be less than or equal to actual
actualthe value generated by the test
namethe name or description of the assertion

◆ assertGe() [2/2]

void org.qore.lang.qunit.Test.assertGe ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests that a value is greater than or equal to an expected value with hard comparisons (types may not differ)

Example:
assertGe(5, method_that_should_rturn_a_value_greater_than_or_equal_to_five());
Parameters
expecteda value that should be less than or equal to actual
actualthe value generated by the test

◆ assertGeSoft() [1/2]

void org.qore.lang.qunit.Test.assertGeSoft ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests that a value is greater than or equal to than an expected value with soft comparisons (types may differ)

Example:
assertGeSoft("5", method_that_should_rturn_a_value_greater_than_or_equal_to_five());
Parameters
expecteda value that should be less than or equal to actual
actualthe value generated by the test
namethe name or description of the assertion

◆ assertGeSoft() [2/2]

void org.qore.lang.qunit.Test.assertGeSoft ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests that a value is greater than or equal to than an expected value with soft comparisons (types may differ)

Example:
assertGeSoft("5", method_that_should_rturn_a_value_greater_than_or_equal_to_five());
Parameters
expecteda value that should be less than or equal to actual
actualthe value generated by the test

◆ assertGt() [1/2]

void org.qore.lang.qunit.Test.assertGt ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests that a value is greater than an expected value with hard comparisons (types may not differ)

Example:
assertGt(5, method_that_should_rturn_a_value_greater_than_five());
Parameters
expecteda value that should be less than actual
actualthe value generated by the test
namethe name or description of the assertion

◆ assertGt() [2/2]

void org.qore.lang.qunit.Test.assertGt ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests that a value is greater than an expected value with hard comparisons (types may not differ)

Example:
assertGt(5, method_that_should_rturn_a_value_greater_than_five());
Parameters
expecteda value that should be less than actual
actualthe value generated by the test

◆ assertGtSoft() [1/2]

void org.qore.lang.qunit.Test.assertGtSoft ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests that a value is greater than an expected value with soft comparisons (types may differ)

Example:
assertGtSoft("5", method_that_should_rturn_a_value_greater_than_five());
Parameters
expecteda value that should be less than actual
actualthe value generated by the test
namethe name or description of the assertion

◆ assertGtSoft() [2/2]

void org.qore.lang.qunit.Test.assertGtSoft ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests that a value is greater than an expected value with soft comparisons (types may differ)

Example:
assertGtSoft("5", method_that_should_rturn_a_value_greater_than_five());
Parameters
expecteda value that should be less than actual
actualthe value generated by the test

◆ assertLe() [1/2]

void org.qore.lang.qunit.Test.assertLe ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests that a value is less than or equal to an expected value with hard comparisons (types may not differ)

Example:
assertLe(5, method_that_should_rturn_a_value_less_than_or_equal_to_five());
Parameters
expecteda value that should be greater than or equal to actual
actualthe value generated by the test
namethe name or description of the assertion

◆ assertLe() [2/2]

void org.qore.lang.qunit.Test.assertLe ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests that a value is less than or equal to an expected value with hard comparisons (types may not differ)

Example:
assertLe(5, method_that_should_rturn_a_value_less_than_or_equal_to_five());
Parameters
expecteda value that should be greater than or equal to actual
actualthe value generated by the test

◆ assertLeSoft() [1/2]

void org.qore.lang.qunit.Test.assertLeSoft ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests that a value is less than or equal to than an expected value with soft comparisons (types may differ)

Example:
assertLeSoft("5", method_that_should_rturn_a_value_less_than_or_equal_to_five());
Parameters
expecteda value that should be greater than or equal to actual
actualthe value generated by the test
namethe name or description of the assertion

◆ assertLeSoft() [2/2]

void org.qore.lang.qunit.Test.assertLeSoft ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests that a value is less than or equal to than an expected value with soft comparisons (types may differ)

Example:
assertLeSoft("5", method_that_should_rturn_a_value_less_than_or_equal_to_five());
Parameters
expecteda value that should be greater than or equal to actual
actualthe value generated by the test

◆ assertLt() [1/2]

void org.qore.lang.qunit.Test.assertLt ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests that a value is less than an expected value with hard comparisons (types may not differ)

Example:
assertLt(5, method_that_should_rturn_a_value_less_than_five());
Parameters
expecteda value that should be greater than actual
actualthe value generated by the test
namethe name or description of the assertion

◆ assertLt() [2/2]

void org.qore.lang.qunit.Test.assertLt ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests that a value is less than an expected value with hard comparisons (types may not differ)

Example:
assertLt(5, method_that_should_rturn_a_value_less_than_five());
Parameters
expecteda value that should be greater than actual
actualthe value generated by the test

◆ assertLtSoft() [1/2]

void org.qore.lang.qunit.Test.assertLtSoft ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests that a value is less than an expected value with soft comparisons (types may differ)

Example:
assertLtSoft("5", method_that_should_rturn_a_value_less_than_five());
Parameters
expecteda value that should be greater than actual
actualthe value generated by the test
namethe name or description of the assertion

◆ assertLtSoft() [2/2]

void org.qore.lang.qunit.Test.assertLtSoft ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests that a value is less than an expected value with soft comparisons (types may differ)

Example:
assertLtSoft("5", method_that_should_rturn_a_value_less_than_five());
Parameters
expecteda value that should be greater than actual
actualthe value generated by the test

◆ assertNeq() [1/2]

void org.qore.lang.qunit.Test.assertNeq ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests a value for inequality to an expected value with hard comparisons (types and values must be identical)

Example:
assertNeq(5, method_that_should_return_five());
Parameters
expectedthe value that should not be equal to the test value with a hard comparison
actualthe value generated by the test
namethe name or description of the assertion

◆ assertNeq() [2/2]

void org.qore.lang.qunit.Test.assertNeq ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests a value for inequality to an expected value with hard comparisons (types and values must be identical)

Example:
assertNeq(5, method_that_should_return_five());
Parameters
expectedthe value that should not be equal to the test value with a hard comparison
actualthe value generated by the test

◆ assertNeqSoft() [1/2]

void org.qore.lang.qunit.Test.assertNeqSoft ( Object  expected,
Object  actual,
String  name 
) throws Throwable
inline

Tests a value for inequality to an expected value with soft comparisons (types may differ)

Example:
assertNeqSoft("5", method_that_should_not_return_five());
Parameters
expectedthe value that should not be equal to the test value with a soft comparison
actualthe value generated by the test
namethe name or description of the assertion

◆ assertNeqSoft() [2/2]

void org.qore.lang.qunit.Test.assertNeqSoft ( Object  expected,
Object  actual 
) throws Throwable
inline

Tests a value for inequality to an expected value with soft comparisons (types may differ)

Example:
assertNeqSoft("5", method_that_should_not_return_five());
Parameters
expectedthe value that should not be equal to the test value with a soft comparison
actualthe value generated by the test

◆ assertNothing() [1/2]

void org.qore.lang.qunit.Test.assertNothing ( Object  actual,
String  name 
) throws Throwable
inline

Tests for no value.

Example:
assertNothing(method_that_should_not_return_a value());
Parameters
actualthe value generated by the test
namethe name or description of the assertion

◆ assertNothing() [2/2]

void org.qore.lang.qunit.Test.assertNothing ( Object  actual) throws Throwable
inline

Tests for no value.

Example:
assertNothing(method_that_should_not_return_a value());
Parameters
actualthe value generated by the test

◆ assertNRegex()

void org.qore.lang.qunit.Test.assertNRegex ( String  regex_pattern,
String  actual,
String  name 
) throws Throwable
inline

Tests that a test value does not pass a regular expression match.

Example:
assertNRegex("regex string", string_method());
Parameters
regex_patternthe regular expression pattern string that the test value should not match
actualthe value generated by the test
namethe name or description of the assertion

◆ assertNumberEq() [1/3]

void org.qore.lang.qunit.Test.assertNumberEq ( BigDecimal  expected,
BigDecimal  actual,
BigDecimal  epsilon,
String  name 
) throws Throwable
inline

Tests a number value for equality to an expected value with an allowed error.

Example:
assertNumberEq(2.5n, 2.50001n, 0.001n);
Parameters
expectedthe expected value
actualthe value generated by the test
epsilonthe allowed error
namethe name or description of the assertion

◆ assertNumberEq() [2/3]

void org.qore.lang.qunit.Test.assertNumberEq ( BigDecimal  expected,
BigDecimal  actual,
BigDecimal  epsilon 
) throws Throwable
inline

Tests a number value for equality to an expected value with an allowed error.

Example:
assertNumberEq(2.5n, 2.50001n, 0.001n);
Parameters
expectedthe expected value
actualthe value generated by the test
epsilonthe allowed error
namethe name or description of the assertion

◆ assertNumberEq() [3/3]

void org.qore.lang.qunit.Test.assertNumberEq ( BigDecimal  expected,
BigDecimal  actual 
) throws Throwable
inline

Tests a number value for equality to an expected value with an allowed error.

Example:
assertNumberEq(2.5n, 2.50001n);
Parameters
expectedthe expected value
actualthe value generated by the test

◆ assertRegex() [1/2]

void org.qore.lang.qunit.Test.assertRegex ( String  regex_pattern,
String  actual,
String  name 
) throws Throwable
inline

Tests that a test value passes a regular expression match.

Example:
assertRegex("regex string", string_method());
Parameters
regex_patternthe regular expression pattern string that the test value should match
actualthe value generated by the test
namethe name or description of the assertion

◆ assertRegex() [2/2]

void org.qore.lang.qunit.Test.assertRegex ( String  regex_pattern,
String  actual 
) throws Throwable
inline

Tests that a test value passes a regular expression match.

Example:
assertRegex("regex string", string_method());
Parameters
regex_patternthe regular expression pattern string that the test value should match
actualthe value generated by the test
namethe name or description of the assertion

◆ assertSkip()

void org.qore.lang.qunit.Test.assertSkip ( String  name) throws Throwable
inline

Skips assertion on purpose.

Parameters
namethe name or description of the assertion
Example:
assertSkip("assertion name or reason to skip");

◆ assertThrows() [1/9]

void org.qore.lang.qunit.Test.assertThrows ( String  expectedErr,
String  expectedDesc,
TestCodeArgs  theCode,
Object []  args,
String  name 
) throws Throwable
inline

Tests that a piece of code throws an exception with given description.

Example:
assertThrows("DIVISION-BY-ZERO", "division by zero found in integer expression", sub(int a) {print(5/a);}, 0);
Parameters
expectedErrthe expected exception type
expectedDescthe expected exception detail (desc field), ignored if NOTHING
theCodethe code to execute
argsoptional arguments to the code
namean optional label for the assertion

◆ assertThrows() [2/9]

void org.qore.lang.qunit.Test.assertThrows ( String  expectedErr,
String  expectedDesc,
TestCodeArgs  theCode,
Object []  args 
) throws Throwable
inline

Tests that a piece of code throws an exception with given description.

Example:
assertThrows("DIVISION-BY-ZERO", "division by zero found in integer expression", sub(int a) {print(5/a);}, 0);
Parameters
expectedErrthe expected exception type
expectedDescthe expected exception detail (desc field), ignored if NOTHING
theCodethe code to execute
argsoptional arguments to the code

◆ assertThrows() [3/9]

void org.qore.lang.qunit.Test.assertThrows ( String  expectedErr,
String  expectedDesc,
TestCodeArgs  theCode 
) throws Throwable
inline

Tests that a piece of code throws an exception with given description.

Example:
assertThrows("DIVISION-BY-ZERO", "division by zero found in integer expression", sub(int a) {print(5/a);}, 0);
Parameters
expectedErrthe expected exception type
expectedDescthe expected exception detail (desc field), ignored if NOTHING
theCodethe code to execute

◆ assertThrows() [4/9]

void org.qore.lang.qunit.Test.assertThrows ( String  expectedErr,
TestCodeArgs  theCode,
Object []  args,
String  name 
) throws Throwable
inline

Tests that a piece of code throws an exception with given description.

Example:
assertThrows("DIVISION-BY-ZERO", "division by zero found in integer expression", sub(int a) {print(5/a);}, 0);
Parameters
expectedErrthe expected exception type
theCodethe code to execute
argsoptional arguments to the code
namean optional label for the assertion

◆ assertThrows() [5/9]

void org.qore.lang.qunit.Test.assertThrows ( String  expectedErr,
TestCodeArgs  theCode,
Object []  args 
) throws Throwable
inline

Tests that a piece of code throws an exception with given description.

Example:
assertThrows("DIVISION-BY-ZERO", "division by zero found in integer expression", sub(int a) {print(5/a);}, 0);
Parameters
expectedErrthe expected exception type
theCodethe code to execute
argsoptional arguments to the code

◆ assertThrows() [6/9]

void org.qore.lang.qunit.Test.assertThrows ( String  expectedErr,
String  expectedDesc,
TestCode  theCode,
String  name 
) throws Throwable
inline

Tests that a piece of code throws an exception with given description.

Example:
assertThrows("DIVISION-BY-ZERO", "division by zero found in integer expression", sub(int a) {print(5/a);}, 0);
Parameters
expectedErrthe expected exception type
expectedDescthe expected exception detail (desc field), ignored if NOTHING
theCodethe code to execute
namean optional label for the assertion

◆ assertThrows() [7/9]

void org.qore.lang.qunit.Test.assertThrows ( String  expectedErr,
String  expectedDesc,
TestCode  theCode 
) throws Throwable
inline

Tests that a piece of code throws an exception with given description.

Example:
assertThrows("DIVISION-BY-ZERO", "division by zero found in integer expression", sub(int a) {print(5/a);}, 0);
Parameters
expectedErrthe expected exception type
expectedDescthe expected exception detail (desc field), ignored if NOTHING
theCodethe code to execute

◆ assertThrows() [8/9]

void org.qore.lang.qunit.Test.assertThrows ( String  expectedErr,
TestCode  theCode,
String  name 
) throws Throwable
inline

Tests that a piece of code throws an exception with given description.

Example:
assertThrows("DIVISION-BY-ZERO", "division by zero found in integer expression", sub(int a) {print(5/a);}, 0);
Parameters
expectedErrthe expected exception type
theCodethe code to execute
namean optional label for the assertion

◆ assertThrows() [9/9]

void org.qore.lang.qunit.Test.assertThrows ( String  expectedErr,
TestCode  theCode 
) throws Throwable
inline

Tests that a piece of code throws an exception with given description.

Example:
assertThrows("DIVISION-BY-ZERO", "division by zero found in integer expression", sub(int a) {print(5/a);}, 0);
Parameters
expectedErrthe expected exception type
theCodethe code to execute

◆ assertTrue() [1/2]

void org.qore.lang.qunit.Test.assertTrue ( Object  actual,
String  name 
) throws Throwable
inline

Tests a boolean value.

Example:
assertTrue(methodThatShouldReturnTrue());
Parameters
actualthe value generated by the test
namethe name or description of the assertion

◆ assertTrue() [2/2]

void org.qore.lang.qunit.Test.assertTrue ( Object  actual) throws Throwable
inline

Tests a boolean value.

Example:
assertTrue(methodThatShouldReturnTrue());
Parameters
actualthe value generated by the test

◆ equals()

boolean org.qore.lang.qunit.Test.equals ( Object  a,
Object  b 
) throws Throwable
inline

Compare two values for equality.

Parameters
aArgument 1
bArgument 2
Returns
a == b

◆ fail()

void org.qore.lang.qunit.Test.fail ( String  msg) throws Throwable
inline

Fails the test unconditionally.

Example:
fail("Unexpected code executed");
Parameters
msgthe failure message

◆ notEquals()

boolean org.qore.lang.qunit.Test.notEquals ( Object  a,
Object  b 
) throws Throwable
inline

Compare two values for inequality.

Parameters
aArgument 1
bArgument 2
Returns
a != b

◆ regexpMatches()

boolean org.qore.lang.qunit.Test.regexpMatches ( String  s,
String  regexp 
) throws Throwable
inline

Compare a string for match against a regexp.

Parameters
sString to match
regexpRegular expression to match against
Returns
a == b

◆ testAssertion() [1/6]

Object org.qore.lang.qunit.Test.testAssertion ( String  name,
TestConditionArgs  condition,
Object []  args,
Object  expectedResultValue 
) throws Throwable
inline

Tests for a single assertion for a call returning an integer value and returns the value generated.

Parameters
namethe name or description of the assertion
conditionA test function whose result we are asserting
argsArguments passed to condition
expectedResultValuethe expected value
Returns
the result of the condition call, if the immediate value has any further use

◆ testAssertion() [2/6]

Object org.qore.lang.qunit.Test.testAssertion ( String  name,
TestCondition  condition,
Object  expectedResultValue 
) throws Throwable
inline

Tests for a single assertion for a call returning an integer value and returns the value generated.

Parameters
namethe name or description of the assertion
conditionA test function whose result we are asserting
expectedResultValuethe expected value
Returns
the result of the condition call, if the immediate value has any further use

◆ testAssertion() [3/6]

Object org.qore.lang.qunit.Test.testAssertion ( String  name,
TestConditionArgs  condition,
Object []  args,
AbstractTestResult  expectedResult 
) throws Throwable
inline

Tests for a single assertion and returns the value generated.

Parameters
namethe name or description of the assertion
conditionA test function whose result we are asserting
argsArguments passed to condition
expectedResultA class describing the expected result of condition; the default is QUnit::TestResultSuccess
Returns
the result of the condition call, if the immediate value has any further use

◆ testAssertion() [4/6]

Object org.qore.lang.qunit.Test.testAssertion ( String  name,
TestConditionArgs  condition,
Object []  args 
) throws Throwable
inline

Tests for a single assertion and returns the value generated.

Parameters
namethe name or description of the assertion
conditionA test function whose result we are asserting
argsArguments passed to condition
Returns
the result of the condition call, if the immediate value has any further use

◆ testAssertion() [5/6]

Object org.qore.lang.qunit.Test.testAssertion ( String  name,
TestCondition  condition,
AbstractTestResult  expectedResult 
) throws Throwable
inline

Tests for a single assertion and returns the value generated.

Parameters
namethe name or description of the assertion
conditionA test function whose result we are asserting
expectedResultA class describing the expected result of condition; the default is QUnit::TestResultSuccess
Returns
the result of the condition call, if the immediate value has any further use

◆ testAssertion() [6/6]

Object org.qore.lang.qunit.Test.testAssertion ( String  name,
TestCondition  condition 
) throws Throwable
inline

Tests for a single assertion and returns the value generated.

Parameters
namethe name or description of the assertion
conditionA test function whose result we are asserting
Returns
the result of the condition call, if the immediate value has any further use

◆ testAssertionValue() [1/5]

Object org.qore.lang.qunit.Test.testAssertionValue ( String  name,
Object  actual,
Object  expected 
) throws Throwable
inline

Tests a value for equality to an expected value.

Example:
testAssertionValue("date > operator", now() > (now() - 1D), True);
Parameters
namethe name or description of the assertion
actualthe value generated by the test
expectedthe expected value
Returns
the value argument
Note
make sure and use testAssertion() for any calls that could throw an exception

◆ testAssertionValue() [2/5]

Object org.qore.lang.qunit.Test.testAssertionValue ( String  name,
BigDecimal  actual,
BigDecimal  expected,
BigDecimal  epsilon 
) throws Throwable
inline

Tests a value for equality to an expected value of number type.

Parameters
namethe name or description of the assertion
actualthe value generated by the test
expectedthe expected value
epsilonaccepted difference
Returns
the actual argument
Note
make sure and use testAssertion() for any calls that could throw an exception

◆ testAssertionValue() [3/5]

Object org.qore.lang.qunit.Test.testAssertionValue ( String  name,
BigDecimal  actual,
BigDecimal  expected 
) throws Throwable
inline

Tests a value for equality to an expected value of number type.

Parameters
namethe name or description of the assertion
actualthe value generated by the test
expectedthe expected value
Returns
the actual argument
Note
make sure and use testAssertion() for any calls that could throw an exception

◆ testAssertionValue() [4/5]

Object org.qore.lang.qunit.Test.testAssertionValue ( String  name,
float  actual,
float  expected,
float  epsilon 
) throws Throwable
inline

Tests a value for equality to an expected value of float type.

Parameters
namethe name or description of the assertion
actualthe value generated by the test
expectedthe expected value
epsilonaccepted difference
Returns
the actual argument
Note
make sure and use testAssertion() for any calls that could throw an exception

◆ testAssertionValue() [5/5]

Object org.qore.lang.qunit.Test.testAssertionValue ( String  name,
float  actual,
float  expected 
) throws Throwable
inline

Tests a value for equality to an expected value of float type.

Parameters
namethe name or description of the assertion
actualthe value generated by the test
expectedthe expected value
epsilonaccepted difference
Returns
the actual argument
Note
make sure and use testAssertion() for any calls that could throw an exception

◆ testNullAssertion() [1/2]

void org.qore.lang.qunit.Test.testNullAssertion ( String  name,
TestConditionArgs  condition,
Object...  args 
) throws Throwable
inline

Tests for a single assertion for a call returning no value (for example, to ensure that the call does not throw an exception)

Parameters
namethe name or description of the assertion
conditionA test function whose result we are asserting
argsArguments passed to condition
Returns
the result of the condition call, if the immediate value has any further use

◆ testNullAssertion() [2/2]

void org.qore.lang.qunit.Test.testNullAssertion ( String  name,
TestCondition  condition 
) throws Throwable
inline

Tests for a single assertion for a call returning no value (for example, to ensure that the call does not throw an exception)

Parameters
namethe name or description of the assertion
conditionA test function whose result we are asserting
Returns
the result of the condition call, if the immediate value has any further use

◆ testSkip() [1/2]

void org.qore.lang.qunit.Test.testSkip ( String  reason,
Object...  args 
) throws Throwable
inline

Skips a given test, eg. because it may be missing some dependencies.

Parameters
reasonThe reason for the test skip; used as the format argument with vsprintf() with any remaining arguments

◆ testSkip() [2/2]

void org.qore.lang.qunit.Test.testSkip ( String  reason) throws Throwable
inline

Skips a given test, eg. because it may be missing some dependencies.

Parameters
reasonThe reason for the test skip

The documentation for this class was generated from the following file: