Functions - test

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.

prepare

Prepares a provided default mock object for stubbing.

startServiceSkeleton

Start a service skeleton from a given OpenApi definition in the given ballerina module.

startServices

Starts all the services defined in the module specified in the 'moduleName' argument.

stopServiceSkeleton

Stop a service skeleton and cleanup created directories of a given ballerina module.

stopServices

Stops all the services defined in the module specified in the 'moduleName' argument.

when

Objects and functions related to function mocking Allows a function to stub.

assertEquals

(any | error actual, any | error expected, string msg)

Asserts whether the given values are equal. If it is not, an AssertError is thrown with the given errorMessage.

Parameters

  • actual any | error
  • Actual value

  • expected any | error
  • Expected value

  • msg string (default Assertion Failed!)
  • Assertion error message

assertFail

(string msg)

Assert failure is triggered based on user discretion. AssertError is thrown with the given errorMessage.

Parameters

  • msg string (default Test Failed!)
  • Assertion error message

assertFalse

(boolean condition, string msg)

Asserts whether the given condition is false. If it is not, a AssertError is thrown with the given errorMessage.

Parameters

  • condition boolean
  • Boolean condition to evaluate

  • msg string (default Assertion Failed!)
  • Assertion error message

assertNotEquals

(any | error actual, any | error expected, string msg)

Asserts whether the given values are not equal. If it is equal, an AssertError is thrown with the given errorMessage.

Parameters

  • actual any | error
  • Actual value

  • expected any | error
  • Expected value

  • msg string (default Assertion Failed!)
  • Assertion error message

assertTrue

(boolean condition, string msg)

Asserts whether the given condition is true. If it is not, a AssertError is thrown with the given errorMessage.

Parameters

  • condition boolean
  • Boolean condition to evaluate

  • msg string (default Assertion Failed!)
  • Assertion error message

createBallerinaError

(string errorMessage, string category)

returns error

Creates an AssertError with custom message and category.

Parameters

  • errorMessage string
  • Custom message for the ballerina error

  • category string
  • error category

  • Return Type

    (error)
  • an AssertError with custom message and category

mock

(typedesc T, T10 mockObject)

returns T11

Creates and returns a mock object of provided type description.

Parameters

  • T typedesc
  • type of object to create the mock

  • mockObject T10 (default BLangTypeInit: new null ([]) )
  • mock object to replace the original (optional)

  • Return Type

    (T11)
  • created mock object

mockHandler

(MockFunction mockFunction, any | error... args)

returns any | Error

Inter-op to handle function mocking.

Parameters

  • args any | error...
  • function arguments

  • Return Type

    (any | Error)
  • function return value or error if case registration failed

prepare

(T14 mockObject)

returns MockObject

Prepares a provided default mock object for stubbing.

Parameters

  • mockObject T14
  • created default mock object

  • Return Type

    (MockObject)
  • prepared object that allows a member function/field to register stubs

startServiceSkeleton

(string moduleName, string openApiFilePath)

returns boolean

Start a service skeleton from a given OpenApi definition in the given ballerina module.

Parameters

  • moduleName string
  • Name of the module

  • openApiFilePath string
  • Path to the OpenApi definition

  • Return Type

    (boolean)
  • true if the service skeleton was started successfully, false otherwise

startServices

(string moduleName)

returns boolean

Starts all the services defined in the module specified in the 'moduleName' argument.

Parameters

  • moduleName string
  • Name of the module

  • Return Type

    (boolean)
  • true if the services were started successfully, false otherwise

stopServiceSkeleton

(string moduleName)

Stop a service skeleton and cleanup created directories of a given ballerina module.

Parameters

  • moduleName string
  • Name of the module

stopServices

(string moduleName)

Stops all the services defined in the module specified in the 'moduleName' argument.

Parameters

  • moduleName string
  • Name of the module

when

(MockFunction mockFunction)

returns FunctionStub

Objects and functions related to function mocking Allows a function to stub.

Parameters

  • Return Type

    (FunctionStub)
  • object that allows stubbing calls to provided function