Software testing and continuous integration

Software testing and continuous integration

"Introduction to testing practices for software development and in particular continuous integration, with a guided hands-on example."

Information

The estimated time to complete this training module is 2h.

The prerequisites to take this module are:

Contact François Paugam if you have questions on this module, or if you want to check that you completed successfully all the exercises.

Resources

This module was presented by Greg Kiar during the QLSC 612 course in 2020, the slides are available here.

⚠ In Greg's presentation he uses Travis-CI.org to do the remote tests on his github repo. Since 2021 Travis-CI.org no longer exists, there is only the commercial Travic-CI.com. So instead we will here use GitHub actions. Thus you can follow the video up until 55:23, then follow the instructions below to setup the Github action workflow.

The video of the presentation is available below:

Exercise

  • Watch the video until 55:23.

  • Fork this repo.

  • On your fork in github, go to the Actions tab and create a new workflow.

  • Modify the action template created by github to :

    • Change the workflow name from “build” to “test”
    • add the following step to setup python :
          # Set up python to be able to run python scripts
          - name: Set up Python
            uses: actions/setup-python@v1
            with:
              python-version: 3.7
    
    • add the following step to install the dependancies :
          # Pip install the required packages
          - name: Install Dependencies
            run: pip install -r requirements.txt
    
    • Run the test script :
          # Run the test script
          - name: Run test
            run: |
              cd code
              bash test.sh
    
  • commit and push this new file to create and run the action.

  • go back to the action tab on your repo, you should see an action called “test”.

  • verify that the action did run the test, the first one should be passed and the second should fail, so you should be able to see something like that :

    Action example
  • Follow up with François Paugam to validate you completed the exercise correctly.

  • 🎉 🎉 🎉 you completed this training module! 🎉 🎉 🎉

More resources

The pytest library is the go-to way to implement unit tests in python. If you intend to do unit testing in python, you should get familiar with this tool; either through the pytest documentation, with a tutorial such as this one or watching this PyConDE keynote.


Illustration by Nikita Golubev.