Learn how to test your SQLite exercises on Exercism
To run the tests for your SQLite exercises, follow these steps:
${slug}_test.sql
file, where ${slug}
is the name of the exercise, using hyphens instead of spaces and all lowercase.sqlite3 -bail < ${slug}_test.sql
This command initializes SQLite with an empty database, runs the tests specified in ${slug}_test.sql
, and exits afterward.
-bail
will make sure the code execution stops for invalid code.
The test results will be displayed in the console as a table, showing the description of each test, its status (e.g., "pass"), and a message if the status is "fail."
You can use SELECT
statements for debugging.
The output will be forwarded to user_output.md
and shown in the web-editor if tests fail.
The test file (${slug}_test.sql
) is a pretty complex script.
Here is an overview of what it does.
create_fixture.sql
.
This creates tables then populates them with values from data.csv
for valid data and error_data.csv
for entries that should fail.
Only those tables are checked during tests; changes to other tables are ignored.${slug}.sql
file.