(inside a function):
[container.image] repository = "myorg/myapi" name = "myapi" tag = "v1.0" Ballerina includes a built-in test framework.
worker w1 returns int return 10;
Ballerina uses strands – lightweight threads managed by the runtime. Use start , wait , and isolated functions.
Run tests:
bal test myproject/ ├── Ballerina.toml # module metadata, dependencies ├── main.bal # entry point ├── modules/ │ └── auth/ # submodule │ ├── Module.md │ └── auth.bal ├── tests/ # test files │ └── main_test.bal └── target/ # build output Create a new project:
import ballerina/test; @Test function testAddition() int result = 2 + 2; test:assertEquals(result, 4); ballerina
bal run hello.bal Variables & Types int age = 30; string name = "Alice"; boolean active = true; float pi = 3.14; decimal precise = 10.0d; byte[] data = [1, 2, 3]; json j = "name": "Bob" ; xml x = `<person>John</person>`; Optional Types & Error Handling Ballerina uses optional types ( T? ) and error union types ( T|error ).
Cloud.toml :
string? maybeName = "Jane"; maybeName = (); // nil function divide(int a, int b) returns int|error if b == 0 return error("Division by zero");
worker w2 returns int return 20;