4. Automated Testing - GeorgeCiesinski/text-script GitHub Wiki

Current Build Status

https://travis-ci.com/github/GeorgeCiesinski/text-script

Testing Introduction

New branches made on this repository, as well as new pull requests, are automatically built and tested by Travis CI. Please ensure that you create a new test for any new functions or modules that you write. We are currently using the Pytest library for our testing. Please see the tests/test_glib.py file for an example.

To ensure that a single standard is being followed, please write the tests as per below:

Test Rules / Adding new tests

  1. For each module in the "textscript" directory, there should be a test script named test_$MODULE.py in the "tests" directory where $MODULE matches the module name.
  2. If you add a new module, please make a new test script for this module as per step 1.
  3. If you add a new function to an existing module, go to its corresponding test module and write a function that looks like:

def test_FUNCTION_NAME():

Local Testing

You can run the tests by running

pytest

in the root directory

More Information (Provided by jwlodek)

  • It currently does work on all branches and PRs. If you don't want that, you can edit the .travis.yml file and add a job. There you can specify an action to perform given certain conditions, like only running tests on master, or on tag creating new release versions. For now it is just the super basic "run the tests on all branches". When there is a PR, it will run on the merging branch, and will tell you if all the unit tests pass for it.
  • For projects that end up on PyPi, the requirements.txt file is used to know which dependencies should also be installed with pip install. Usually, end users don't care about things like unit testing, and debug logging, so packages specific to that are placed in a separate file (that also contains the same packages as requirements.txt) for developers and CI. It isn't super important, just a conveniance.
  • Automated testing was added in this commit: https://github.com/GeorgeCiesinski/text-script/issues/53

Resources

  1. How to configure jobs on Travis CI: link
  2. Pytest documentation: link