So the other day I pulled a FSM template from the Network to Code NTC Templates repo. I discovered there was an issue with the specific template I wanted, and therefore decided to fix it and submit a pull request to the repo. (obviously I did this by forking the repository on GitHub)

The Network to Code folks insist that before any template modifications can be accepted into the repository it must pass the Travis CI test functions first. I went to the website, signed in with my github ID and allowed it to use the forked repo. When I then committed my change I discovered that Travis CI was automatically running the test.

Travis CI

The Travis CI integration works by processing the travis.yml file in the root folder of the repository. The file defined is very simple. It was pretty cool to see this whole test run happen automatically.


language: python

  - "3.6"

sudo: false

  - pip install tox

  - tox

However, the first two attempts to successfully run the tests failed. The first failure was not unexpected - I had not completed the output tests and expected it to fail, but it is less than ideal (and takes a while) to have a commit->push->travis_ci cycle for testing. It did not take long to realised that of course I could run the tests locally before pushing them into the wider world.


For future template developments I will be using tox to check the testing before committing to github. tox uses tox.ini in the root folder of the repository to define the test environment - one issue I came accross is that on my personal Macbook I had python 3.7 installed and tox was looking for python3.6 - editing the tox.ini as follows solved that:

envlist = py37

deps =

whitelist_externals =

commands = pytest

(A useful feature is that if you are running PyCharm you can right click on the tox.ini file to run the testing suite.)

As far as I can tell, running tox means it runs the full set of tests - it might be useful to only run for the specific template you’re working on, but I have yet to work out how to do that.