This Gitpod environment is set up with everything you need to run and test the example programs in Nada by Example.
Every Nada program example has a corresponding test file. Programs are in nada-by-example/src/
and test files are in nada-by-example/tests
. Running a program uses the inputs specified in the test file. Testing a program uses the inputs specified in the test file and also checks the outputs against the expected_outputs
specified in the test file.
Run any program with the inputs specified in the test file with nada run
nada run <test-file-name>
To run the addition program with addition_test
test inputs:
nada run addition_test
The result of running this program is
(.venv) ➜ nada-by-example git:(main) nada run addition_test
Running program 'addition' with inputs from test file addition_test
Building ...
Running ...
Program ran!
Outputs: {
"sum": SecretInteger(
NadaInt(
40,
),
),
}
Test any program with the inputs and outputs specified in the test file with nada test
nada test <test-file-name>
Test the addition program with addition_test
test inputs and expected outputs:
nada test addition_test
The result of testing this program is
(.venv) ➜ nada-by-example git:(main) nada test addition_test
Running test: addition_test
Building ...
Running ...
addition_test: PASS
Testing the addition program with addition_test
results in a PASS because the expected_outputs sum
output matches the run result.
Use the nada tool to add a new test file named "addition_test_2" for the addition example.
nada generate-test --test-name addition_test_2 addition
This results in a new test file: /tests/addition_test_2.yaml
(.venv) ➜ nada-by-example git:(main) nada generate-test --test-name addition_test_2 addition
Generating test 'addition_test_2' for
Building ...
Generating test file ...
Test generated!
Update the values in the test file to anything you want, for example:
---
program: addition
inputs:
num_1:
SecretInteger: '100'
num_2:
SecretInteger: '10'
expected_outputs:
sum:
SecretInteger: '110'
nada run addition_test_2
nada test addition_test_2
🥳 You're all set up to run and test any example in nada-by-example. Keep exploring what's possible with Nada by running the rest of the programs in the repo.