Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Add pytest unit testing framework #290
This PR adds the pytest unit testing framework to mautrix-telegram. It does so by exemplarily adding test cases for the module
Tests can be run by executing
In this PR
Adding unit testing to a project improves its overall reliability as it limits the time that is needed for hunting down and fixing bugs. This is done by
I chose the commands handler module as a good starting point for implementing unit testing in mautrix telegram, because it it was already isolated enough to be able to quickly write tests for it. But at the same time the module was complex enough to use a broad range of testing techniques including fixtures, parametrization, mocking and testing of asynchronous methods.
The pytest framework was chosen over the unittest module of the standard lib as it allows a more powerful but also more elegant way of creating test cases and allows for frictionless handling of a async methods.
New dependencies (for testing only) are:
The code change was tested on my private Matrix HS and all test cases pass (obviously
Note: I chose to add all tests in a separate folder called