Module : test
Module overview
This module allow developers to write testable code.
Samples
Following sample shows how to use assertions in Testerina.
import ballerina/test;
@test:Config{}
function testAssertIntEquals() {
int answer = 0;
int a = 5;
int b = 3;
answer = intAdd(a, b);
test:assertEquals(answer, 8, msg = "int values not equal");
}
function intAdd(int a, int b) returns (int) {
return (a + b);
}
| Detail |
The details of an error. |
| MockConfig |
Configuration of the function to be mocked. |
| TestConfig |
Configuration set for test functions. |
| FunctionStub |
Represents an object that allows stubbing function invocations |
| MemberFunctionStub |
Represents an object that allows stubbing member function invocations. |
| MemberVariableStub |
Represents an object that allows stubbing member variables retrieved. |
| MockFunction |
Represents a MockFunction object |
| MockObject |
Represents a Mock object in which to create stubs for member functions and variables |
| assertEquals |
Asserts whether the given values are equal. |
| assertFail |
Assert failure is triggered based on user discretion. |
| assertFalse |
Asserts whether the given condition is false. |
| assertNotEquals |
Asserts whether the given values are not equal. |
| assertTrue |
Asserts whether the given condition is true. |
| createBallerinaError |
Creates an AssertError with custom message and category. |
| mock |
Creates and returns a mock object of provided type description. |
| mockHandler |
Inter-op to handle function mocking. |
| mockStringHandler |
Inter-op to handle function mocking which return string |
| prepare |
Prepares a provided default mock object for stubbing. |
| toString |
Java implementation of toString |
| when |
Objects and functions related to function mocking Allows a function to stub. |
| ANY |
Represents the placeholder to be given for object or record type arguments |
| INVALID_OBJECT_ERROR |
Represents the reason for the mock object related errors. |
| FUNCTION_NOT_FOUND_ERROR |
Represents the reason for the non-existing member function related errors. |
| FUNCTION_SIGNATURE_MISMATCH_ERROR |
Represents the reason for the function signature related errors. |
| INVALID_MEMBER_FIELD_ERROR |
Represents the reason for the object member field related errors. |
| FUNCTION_CALL_ERROR |
Represents the reason for function mocking related errors. |
| AfterEach |
Identifies afterTest function. |
| AfterSuite |
Identifies afterSuite function. |
| BeforeEach |
Identifies beforeTest function. |
| BeforeSuite |
Identifies beforeSuite function. |
| Config | |
| Mock |
Identifies the MockFunction object |
| Error |
Represents mocking related errors |
| FunctionCallError | |
| FunctionNotFoundError | |
| FunctionSignatureMismatchError | |
| InvalidMemberFieldError | |
| InvalidObjectError |