[26:21] static (extern: com.aussom.stdlib.ATest) extends: object
Implements various static test functions. All expect* helpers throw an Aussom exception on failure and return true on success. Every helper takes an optional trailing Msg parameter that is prepended to the failure message so test authors can record why the assertion should hold.
mkMsg (Msg, string Base)
Internal helper: prepend the optional Msg to a base failure string, separated by " :: ". Returns just the base when Msg is null or empty. Exposed so test authors writing their own expect* helpers can produce consistent failure messages.
Msg Optional caller-supplied message.Base Base failure description.A composed string.expect (Item, ToBe, string Msg = null)
Expect helper function compares two items for equality.
Item is the first item to compare.ToBe is the second item to compare.Msg is an optional message included on failure.A bool with true if equal and throws an exception if not.expectNotNull (Item, string Msg = null)
Expect helper function expects value to not be null.
Item is the item to check.Msg is an optional message included on failure.A bool with true if not null and throws an exception if not.expectNull (Item, string Msg = null)
Expect helper function expects value to be null.
Item is the item to check.Msg is an optional message included on failure.A bool with true if null and throws an exception if not.expectString (Item, string Msg = null)
Expect helper function expects the provided item to be a string.
Item is the item to check.Msg is an optional message included on failure.A bool with true if the item is a string and throws an exception if not.expectBool (Item, string Msg = null)
Expect helper function expects the provided item to be a bool.
Item is the item to check.Msg is an optional message included on failure.A bool with true if the item is a bool and throws an exception if not.expectInt (Item, string Msg = null)
Expect helper function expects the provided item to be an int.
Item is the item to check.Msg is an optional message included on failure.A bool with true if the item is a int and throws an exception if not.expectDouble (Item, string Msg = null)
Expect helper function expects the provided item to be a double.
Item is the item to check.Msg is an optional message included on failure.A bool with true if the item is a double and throws an exception if not.expectNumber (Item, string Msg = null)
Expect helper function expects the provided item to be a type of number.
Item is the item to check.Msg is an optional message included on failure.A bool with true if the item is a type of number and throws an exception if not.expectList (Item, string Msg = null)
Expect helper function expects the provided item to be a list.
Item is the item to check.Msg is an optional message included on failure.A bool with true if the item is a list and throws an exception if not.expectMap (Item, string Msg = null)
Expect helper function expects the provided item to be a map.
Item is the item to check.Msg is an optional message included on failure.A bool with true if the item is a map and throws an exception if not.expectObject (Item, string ClassName, string Msg = null)
Expect helper function expects the provided item to be an object.
Item is the item to check.ClassName is the class name to check against.Msg is an optional message included on failure.A bool with true if the item is an object and throws an exception if not.expectCallback (Item, string Msg = null)
Expect helper function expects the provided item to be a callback.
Item is the item to check.Msg is an optional message included on failure.A bool with true if the item is a callback and throws an exception if not.expectTrue (Item, string Msg = null)
Expect helper function expects the value to be true.
Item is the item to check.Msg is an optional message included on failure.A bool with true on pass and throws an exception if not.expectFalse (Item, string Msg = null)
Expect helper function expects the value to be false.
Item is the item to check.Msg is an optional message included on failure.A bool with true on pass and throws an exception if not.expectClose (double A, double B, double Tolerance = 1.0E-4, string Msg = null)
Expect helper compares two doubles within a tolerance. Useful for floating-point math where exact equality is brittle.
A is the first value.B is the second value.Tolerance is the allowed absolute difference (default 0.0001).Msg is an optional message included on failure.A bool with true on pass and throws an exception if not.expectThrows (callback Cb, string Msg = null)
Expect helper that asserts the provided callback throws when invoked. Aussom propagates AussomException automatically, so exception-path tests must use try-catch.
Cb is a callback to invoke.Msg is an optional message included on failure.A bool with true on pass and throws an exception if not.expectThrowsMessage (callback Cb, string Substr, string Msg = null)
Like expectThrows but also asserts the thrown exception's text contains the provided substring.
Cb is a callback to invoke.Substr is the substring expected in the exception text.Msg is an optional message included on failure.A bool with true on pass and throws an exception if not.expectContains (list Lst, Item, string Msg = null)
Expect helper for list membership. Uses list.contains internally.
Lst is the list to search.Item is the item to find.Msg is an optional message included on failure.A bool with true on pass and throws an exception if not.expectKey (map M, string Key, string Msg = null)
Expect helper for map key presence.
M is the map to query.Key is the key to look for.Msg is an optional message included on failure.A bool with true on pass and throws an exception if not.expectSize (Collection, int N, string Msg = null)
Expect helper for collection size. Accepts list, map, or string. Uses Aussom's '#' length operator.
Collection is a list, map, or string.N is the expected length.Msg is an optional message included on failure.A bool with true on pass and throws an exception if not.expectMatches (string S, string RegexStr, string Msg = null)
Expect helper that asserts a string matches a regular expression. Uses Java regex syntax via the regex.match() utility.
S is the string to test.RegexStr is a Java-syntax regex pattern.Msg is an optional message included on failure.A bool with true on pass and throws an exception if not.fail (string Msg)
Explicit failure with a human-readable message. Equivalent to 'throw "fail(): " + Msg' but reads more naturally inside a test.
Msg is the failure message.Throws an exception every time; never returns.runTestsForClass (string ClassName)
Runs the unit tests for the provided class name and returns a unit test result with the results. Individual messages are logged to standard out. This function requires test.aussom.runner security manager property to be set to true to run this.
ClassName is a string with the class name to run.[329:21] static (extern: com.aussom.stdlib.ATestRunner) extends: object
loadTestFile (string TestsScriptFileName)
Loads a test file with the provided file name and path. This function also identifies and saves the test classes that can be ran.
TestScriptFileName is a string with the script file to load.this objectloadTestString (string FileNameStr, string AussomCodeString)
Loads a test file with the provided file name string contents. This function also identifies and saves the test classes that can be ran.
FileNameStr is a string with the name to give to the code provided. This will be the file name the code is attached to. This can be a made up name, it just can't be the same as other loaded file names.AussomCodeString is a string with the code to load.this objectgetTestClasses ()
Gets a list of test classes that have been loaded.
A list of test class names that have been loaded.getTestFunctions (string TestClassName)
Gets a list of test functions for the provided class name.
TestClassName is a string with the test class to use.A list of test function names that have been loaded.hasBefore (string TestClassName)
Checks to see if the @Before function is set.
TestClassName is a string with the test class to use.A bool with true for set and false for not.hasAfter (string TestClassName)
Checks to see if the @After function is set.
TestClassName is a string with the test class to use.A bool with true for set and false for not.hasBeforeEach (string TestClassName)
Checks to see if the @BeforeEach function is set. @BeforeEach fires before every individual @Test method.
TestClassName is a string with the test class to use.A bool with true for set and false for not.hasAfterEach (string TestClassName)
Checks to see if the @AfterEach function is set. @AfterEach fires after every individual @Test method, regardless of pass or fail.
TestClassName is a string with the test class to use.A bool with true for set and false for not.hasOnTestFail (string TestClassName)
Checks to see if the @OnTestFail function is set. @OnTestFail fires after a @Test method that failed or threw, before any
hook runs.TestClassName is a string with the test class to use.A bool with true for set and false for not.getTestTags (string TestClassName, string TestFunctionName)
Returns the parsed tag list for a single @Test method. Tags come from the comma-separated tags arg on @Test, e.g.
= "...", tags = "slow,db").TestClassName is a string with the test class to use.TestFunctionName is the name of the @Test function.A list of strings with the tags (empty when none).getTestTimeoutMs (string TestClassName, string TestFunctionName)
Returns the parsed timeoutMs value for a single @Test method. 0 means "no timeout". The base runner does not enforce this; a downstream runner (e.g. the aussom CLI) reads the value here and applies a watchdog. See design/aunit-upgrade-eval.md (M8b).
TestClassName is a string with the test class to use.TestFunctionName is the name of the @Test function.An int with the timeout in milliseconds.setIncludeTags (list Tags)
Sets the include-tag filter. When non-empty, only tests whose tag set intersects the provided list are run. Untagged tests are skipped under an include filter.
Tags is a list of strings with the tags to include. Pass an empty list to clear the filter.this object.setExcludeTags (list Tags)
Sets the exclude-tag filter. Tests whose tag set intersects the provided list are skipped. Exclude wins over include when a test matches both.
Tags is a list of strings with the tags to exclude. Pass an empty list to clear the filter.this object.shouldRun (string TestClassName, string TestFunctionName)
Returns whether a single @Test method would run under the current include/exclude tag filters. Useful for verifying filter logic without actually running the test.
TestClassName is a string with the test class to use.TestFunctionName is the name of the @Test function.A bool with true if the test would run, false if filtered out.runClassTests (string TestClassName)
Runs every @Test method in the named test class through the full per-test loop (so @BeforeEach, @AfterEach, @OnTestFail, and tag filters all apply). Returns a result map with keys total, skipped, passed, failed. Useful for tests that need to observe how the runner handles failing tests, hook errors, or filtered tests without polluting the outer test suite's pass/fail counts.
TestClassName is a string with the test class to use.A map with int values for keys 'total', 'skipped', 'passed', and 'failed'.runBefore (string TestClassName)
Runs the @Before function.
TestClassName is a string with the test class to use.this objectrunAfter (string TestClassName)
Runs the @After function.
TestClassName is a string with the test class to use.this objectrunTest (string TestClassName, string TestFunctionName)
Runs the function test with the provided function name. Note that the test must be annotated with @Test or it will fail.
TestClassName is a string with the test class to use.TestFunctionName is a string with the test function name.A bool with true for success and false for failure.clearClassObjectCache ()
Clears the class object cache. One object per class is stored and reused to maintain consisitency between class function. This function clears that cache.