Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Writing Unit Tests with pytest for Runestone Server

Bradley Miller edited this page Apr 18, 2019 · 1 revision

Unit Tests

Testing a system like Runestone takes discipline and some hard work to get started. This project did not start out with a "testing first" philosophy, and its a hard philosophy to enforce in the combination of production and research oriented world that Runestone lives in. We benefit greatly from the research work done by professors and their PhD and masters students at many institutions. At the same time, Runestone.academy serves hundreds of schools and many thousands of students every day. We can't have things breaking in the middle of class. We need to be able to add new features and deploy them with confidence. This will come with a solid testing framework in place.

When To write a unit test

How to write a unit test

Many tests have common needs. Things such as:

  • create a class
  • populate many of the database tables related to a book for that class
  • create an instructor for the class
  • create some students for the class
  • create an instructor for the class
  • simulating student activities for those students.

For these kinds of common activities we have fixtures that allow you to focus on writing tests that test what you are building rather than reinventing the wheel to set up a class and database with all the data you would need.