import ballerina/test;
import ballerina/io;
function beforeFunc () {
io:println("I'm the before function!");
}
@test:Config{
dependsOn:["testFunction3"]
}
function testFunction1 () {
io:println("I'm in test function 1!");
test:assertTrue(true , msg = "Failed!");
}
@test:Config{
dependsOn:["testFunction1"]
}
function testFunction2 () {
io:println("I'm in test function 2!");
test:assertTrue(true , msg = "Failed!");
}@test:Config
function testFunction3 () {
io:println("I'm in test function 3!");
test:assertTrue(true , msg = "Failed!");
}
Testerina Depends OnYou can provide a list of function names the test function depends on, and will be run before the test execution. This will allow you to make sure that tests run in the expected order. |
|
import ballerina/test;
import ballerina/io;
|
|
function beforeFunc () {
io:println("I'm the before function!");
}
|
Before test function |
@test:Config{
dependsOn:["testFunction3"]
}
function testFunction1 () {
io:println("I'm in test function 1!");
test:assertTrue(true , msg = "Failed!");
}
|
Test function |
@test:Config{
dependsOn:["testFunction1"]
}
function testFunction2 () {
io:println("I'm in test function 2!");
test:assertTrue(true , msg = "Failed!");
}
|
Test function |
@test:Config
function testFunction3 () {
io:println("I'm in test function 3!");
test:assertTrue(true , msg = "Failed!");
}
|
|
$ ballerina test testerina-depends-on.bal
---------------------------------------------------------------------------
T E S T S
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Running Tests of Package: .
---------------------------------------------------------------------------
I'm in test function 3!
I'm in test function 1!
I'm in test function 2!
|
|
Tests run: 3, Passed: 3, Failures: 0, Skipped: 0 - in TestSuite
|
|
---------------------------------------------------------------------------
Results:
|
|
Tests run: 3, Passed: 3, Failures: 0, Skipped: 0
---------------------------------------------------------------------------
Summary:
................................................................... SUCCESS
---------------------------------------------------------------------------
|
|