Introduction

Last updated on 2024-12-19 | Edit this page

Overview

Questions

  • What are the goals of this course?

Objectives

  • To understand the learning outcomees of this course
  • To understand the structure of the practicals

Welcome to Testing and Continuous Integration with Python


This course aims to equip researchers with the skills to write effective tests and ensure the quality and reliability of their research software. No prior testing experience is required! We’ll guide you through the fundamentals of software testing using Python’s Pytest framework, a powerful and beginner-friendly tool. You’ll also learn how to integrate automated testing into your development workflow using continuous integration (CI). CI streamlines your process by automatically running tests with every code change, catching bugs early and saving you time. By the end of the course, you’ll be able to write clear tests, leverage CI for efficient development, and ultimately strengthen the foundation of your scientific findings.

This course has a single continuous project that you will work on throughout the lessons and each lesson builds on the last through practicals that will help you apply the concepts you learn. However if you get stuck or fall behind during the course, don’t worry! All the stages of the project for each lesson are available in the files directory in this course’s materials that you can copy across if needed. For example if you are on lesson 3 and haven’t completed the practicals for lesson 2, you can copy the corresponding folder from the files directory.

By the end of this course, you should:

  • Understand how testing can be used to improve code & research reliability
  • Be comfortable with writing basic tests & running them
  • Be able to construct a simple Python project that incorporates tests
  • Be familiar with testing best practices such as unit testing & the AAA pattern
  • Be aware of more advanced testing features such as fixtures & parametrization
  • Understand what Continuous Integration is and why it is useful
  • Be able to add testing to a GitHub repository with simple Continuous Integration

Code of Conduct


This course is covered by the Carpentries Code of Conduct.

As mentioned in the Carpentries Code of Conduct, we encourage you to:

  • Use welcoming and inclusive language
  • Be respectful of different viewpoints and experiences
  • Gracefully accept constructive criticism
  • Focus on what is best for the community
  • Show courtesy and respect towards other community members

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by following our reporting guidelines.

Challenges


This course uses blocks like the one below to indicate an exercise for you to attempt. The solution is hidden by default and can be clicked on to reveal it.

Challenge 1: Talk to your neighbour

  • Introduce yourself to your neighbour
  • Have either of you experienced a time when testing would have been useful?
  • Have either of you written scripts to check that your code is working as expected?
  • Perhaps during a project your code kept breaking and taking up a lot of your time?
  • Perhaps you have written a script to check that your data is being processed correctly?

Key Points

  • This course will teach you how to write effective tests and ensure the quality and reliability of your research software
  • No prior testing experience is required
  • You can catch up on practicals by copying the corresponding folder from the files directory of this course’s materials