LiveCode tests are written as yaml files.
Session Tests verify the exepetced output of the /livecode websocket API.
Each yaml file corresponds to one test with multiple steps. Each step is either a send
or a recv
operation. There is test runner, that reads the yaml files and executes each step, verifying the data received from the app is matching what is specified in the test file.
For example, let's look at the ping test (see sessions/test_ping.yml).
- recv:
msgtype: welcome
message: welcome to livecode
- send:
msgtype: ping
- recv:
msgtype: pong
This has three steps.
- When the connection is estabilished the server greets with a welcome message. All the tests will have this as the first step.
- We are sending a ping message to the server.
- After sending the ping message, the server should respond back with pong message. We are verifying that adding a
recv
step with the expected message.
Similarly, to test helloworld, we would write something like this:
- recv:
msgtype: welcome
message: welcome to livecode
- send:
msgtype: exec
runtime: python
code: print("hello, world!")
- recv:
msgtype: write
file: stdout
data: "hello, world!\n"
The Exec Tests verify the exepetced output of the /exec endpoint.
They are written as follows:
exec:
runtime: python
code: print("hello, world!")
expected_output: "hello, world!\n"
It containes exec
with the message to send to engine and the exepected output from it.
Do you want to try adding a new test?