Learn how to test your Ballerina exercises on Exercism
Follow the steps below to develop a solution for an exercise and test it locally.
Open a Command Prompt and execute the command below with the name of the preferred exercise to download it.
exercism download --track ballerina --exercise <exercise-name>
Execute the command below to navigate to the directory of the newly downloaded exercise.
Tip: The directory location in the command below depends on your OS and your configured Exercism workspace. You can find out your workspace location by executing the
exercism configure
command.
cd ~/exercism/ballerina/hello-world/
Follow the provided instructions and develop a solution for the exercise.
Some Ballerina exercises will have a single test, while others will have multiple tests. The tests can be found in the respective test file of the /tests
directory inside the root directory of the exercise.
Execute the command below to run the test of the exercise.
By default, only the first test is enabled. This is intentional as it allows you to focus on just making that one test pass.
bal test
Follow the steps below to test an exercise with multiple tests.
Once the first test passes, enable the next test by removing the enable: false
property of the @test:Config
annotation.
@test:Config {
enable: false
}
function nextTestCase() {
}
Execute the command below to run the enabled test.
bal test
You have successfully completed the exercise by enabling all tests and making sure that your implementation passes each one.
Good luck and have fun solving the exercises!
If you need any help, do not forget to reach out on the channels below.