import ballerina/io;
import ballerina/test;
// Executed before the `testFunction` function.
function beforeFunc() {
io:println("I'm the before function!");
}
// The Test function.
// The `before` and `after` attributes are used to define the functions
// that need to be executed before and after this test function.
@test:Config {
before: beforeFunc,
after: afterFunc
}
function testFunction() {
io:println("I'm in test function!");
test:assertTrue(true, msg = "Failed!");
}
// Executed after the `testFunction` function.
function afterFunc() {
io:println("I'm the after function!");
}
Before and after testThe |
import ballerina/io;
import ballerina/test;
function beforeFunc() {
io:println("I'm the before function!");
}
Executed before the testFunction
function.
@test:Config {
before: beforeFunc,
after: afterFunc
}
function testFunction() {
io:println("I'm in test function!");
test:assertTrue(true, msg = "Failed!");
}
The Test function.
The before
and after
attributes are used to define the functions
that need to be executed before and after this test function.
function afterFunc() {
io:println("I'm the after function!");
}
Executed after the testFunction
function.
bal test test_module
Compiling source
ballerinatest/test_module:0.1.0
Running tests
ballerinatest/test_module:0.1.0
I'm the before function!
I'm in test function!
I'm the after function!
[pass] testFunction
1 passing
0 failing
0 skipped