ballerina/test package
Annotations
Name | Attachement Points | Data Type | Description |
---|---|---|---|
AfterEach | function | - | Identifies afterTest function. |
AfterSuite | function | - | Identifies afterSuite function. |
BeforeEach | function | - | Identifies beforeTest function. |
BeforeSuite | function | - | Identifies beforeSuite function. |
Config | function | TestConfig | |
Mock | function | MockConfig |
Records Summary
Record | Description | ||
---|---|---|---|
MockConfig | Configuration of the function to be mocked. | ||
TestConfig | Configuration set for test functions. |
Functions Summary
Return Type | Function and Description | ||
---|---|---|---|
assertEquals(any actual, any expected, string msg) Asserts whether the given values are equal. If it is not, an AssertError is thrown with the given errorMessage. |
|||
assertFail(string msg) Assert failure is triggered based on user discretion. AssertError is thrown with the given errorMessage |
|||
assertFalse(boolean condition, string msg) Asserts whether the given condition is false. If it is not, a AssertError is thrown with the given errorMessage |
|||
assertNotEquals(any actual, any expected, string msg) Asserts whether the given values are not equal. If it is equal, an AssertError is thrown with the given errorMessage. |
|||
assertTrue(boolean condition, string msg) Asserts whether the given condition is true. If it is not, a AssertError is thrown with the given errorMessage |
|||
error | createBallerinaError(string errorMessage, string category) Creates an AssertError with custom message and category |
||
boolean | startServiceSkeleton(string packageName, string swaggerFilePath) Start a service skeleton from a given Swagger definition in the given ballerina package. |
||
boolean | startServices(string packageName) Starts all the services defined in the package specified in the 'packageName' argument |
||
stopServiceSkeleton(string packageName) Stop a service skeleton and cleanup created directories of a given ballerina package. |
|||
stopServices(string packageName) Stops all the services defined in the package specified in the 'packageName' argument |
public type MockConfig
Configuration of the function to be mocked.
Field Name | Data Type | Default Value | Description |
---|---|---|---|
packageName | string | . | Name of the package that the function to be mocked resides in |
functionName | string | Name of the function to be mocked |
public type TestConfig
Configuration set for test functions.
Field Name | Data Type | Default Value | Description |
---|---|---|---|
enable | boolean | true | Flag to enable/disable test functions |
groups | string[] | List of groups that this test function belongs to | |
dataProvider | string | Name of the function which will be used to feed data into this test | |
before | string | Name of the function to be run before the test is run | |
after | string | Name of the function to be run after the test is run | |
dependsOn | string[] | A list of function names the test function depends on, and will be run before the test |
public function assertEquals(any actual, any expected, string msg)
Asserts whether the given values are equal. If it is not, an AssertError is thrown with the given errorMessage.
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
actual | any | Actual value | |
expected | any | Expected value | |
msg | string | Assertion Failed! | Assertion error message |
public function assertFail(string msg)
Assert failure is triggered based on user discretion. AssertError is thrown with the given errorMessage
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
msg | string | Test Failed! | Assertion error message |
public function assertFalse(boolean condition, string msg)
Asserts whether the given condition is false. If it is not, a AssertError is thrown with the given errorMessage
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
condition | boolean | Boolean condition to evaluate | |
msg | string | Assertion Failed! |
public function assertNotEquals(any actual, any expected, string msg)
Asserts whether the given values are not equal. If it is equal, an AssertError is thrown with the given errorMessage.
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
actual | any | Actual value | |
expected | any | Expected value | |
msg | string | Assertion Failed! | Assertion error message |
public function assertTrue(boolean condition, string msg)
Asserts whether the given condition is true. If it is not, a AssertError is thrown with the given errorMessage
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
condition | boolean | Boolean condition to evaluate | |
msg | string | Assertion Failed! | Assertion error message |
public function createBallerinaError(string errorMessage, string category) returns (error)
Creates an AssertError with custom message and category
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
errorMessage | string | Custom message for the ballerina error | |
category | string | error category |
Return Type | Description | ||
---|---|---|---|
error |
public function startServiceSkeleton(string packageName, string swaggerFilePath) returns (boolean)
Start a service skeleton from a given Swagger definition in the given ballerina package.
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
packageName | string | Name of the package | |
swaggerFilePath | string | Path to the Swagger definition |
Return Type | Description | ||
---|---|---|---|
boolean |
public function startServices(string packageName) returns (boolean)
Starts all the services defined in the package specified in the 'packageName' argument
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
packageName | string | Name of the package |
Return Type | Description | ||
---|---|---|---|
boolean |
public function stopServiceSkeleton(string packageName)
Stop a service skeleton and cleanup created directories of a given ballerina package.
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
packageName | string | Name of the package |
public function stopServices(string packageName)
Stops all the services defined in the package specified in the 'packageName' argument
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
packageName | string | Name of the package |