Unit Testing in Python

Tijdsduur
Locatie
Op locatie
Startdatum en plaats

Unit Testing in Python

Info Support
Logo van Info Support
Opleiderscore: starstarstarstarstar_border 8,3 Info Support heeft een gemiddelde beoordeling van 8,3 (uit 15 ervaringen)

Tip: meer info over het programma, prijs, en inschrijven? Download de brochure!

Startdata en plaatsen
placeUtrecht
1 dec. 2025 tot 2 dec. 2025
Toon rooster
event 1 december 2025, 09:00-16:00, Utrecht
event 2 december 2025, 09:00-16:00, Utrecht
Beschrijving

Meer weten over de onderwerpen die aan bod komen en de vereiste voorkennis? Neem vrijblijvend contact met ons op.

Be more productive by practicing Test-Driven Development (TDD), leveraging advanced tools and frameworks and applying specialized code patterns.

Description

This practical course will teach you everything you need to know to write effective and maintainable unit tests using Python.

  You'll learn how to use Test-driven development (TDD) to catch bugs early, as well as when to use black-box vs. white-box testing. We'll also dive into the 'world of mocking' with the unittest.mocking library, showing you why and how to use it effectively. You'll learn about coverage metrics like code coverage and mutation testing, and we'll explore best practices to help you write efficient and high-quality tes…

Lees de volledige beschrijving

Veelgestelde vragen

Er zijn nog geen veelgestelde vragen over dit product. Als je een vraag hebt, neem dan contact op met onze klantenservice.

Nog niet gevonden wat je zocht? Bekijk deze onderwerpen: Unit Testing, Python, Software Testing, Penetration testing en Acceptatie Testen.

Meer weten over de onderwerpen die aan bod komen en de vereiste voorkennis? Neem vrijblijvend contact met ons op.

Be more productive by practicing Test-Driven Development (TDD), leveraging advanced tools and frameworks and applying specialized code patterns.

Description

This practical course will teach you everything you need to know to write effective and maintainable unit tests using Python.

  You'll learn how to use Test-driven development (TDD) to catch bugs early, as well as when to use black-box vs. white-box testing. We'll also dive into the 'world of mocking' with the unittest.mocking library, showing you why and how to use it effectively. You'll learn about coverage metrics like code coverage and mutation testing, and we'll explore best practices to help you write efficient and high-quality tests.

We will end by implementing integration testing with Testcontainers, so you can be confident that your code works seamlessly with other parts of your system.

At the end of this course, you'll be well-equipped to write unit tests that catch bugs early, reduce maintenance costs, and help you become a better Python developer.

AI-Boosted: You'll learn how to generate unit tests with Github Copilot, and how to influence generation results using a Github Copilot instruction file.

Learning Goals

  • Construct effective basic unit tests. [Apply]
  • Understand the principles of the testing pyramid and its role in shaping an effective testing strategy. [Understand]
  • Apply the Test-driven development (TDD) methodology when creating unit tests and production code. [Apply]
  • Apply the concept of mocking in your unit tests with a common mock framework. [Apply]
  • Investigate the different ways of how to measure the quality of your test code. [Analyze]
  • Construct unit tests using the de facto frameworks. [Apply]
  • Construct integration tests using TestContainers. [Apply]
  • Explain best practices for maintainable tests. [Understand]

Subjects

  1. About testing
  2. Unit testing basics
  3. Test-driven development (TDD)
  4. Concept of mocking
  5. Code coverage
  6. Mocking with unittest.mock
  7. Testing frameworks
  8. Best practices
  9. Mutation testing
  10. Integration testing
About testing

In this chapter, you will learn the basics of testing. Why we test and what kind of tests there are.

Goals:

  • Know the difference between linting and testing.
  • Learn how to categorize all the different kinds of tests.
  • Know the testing pyramid and how it can help you to reason about test levels.
  • Learn the common anti-patterns and how to recognize them
Unit testing basics

In this chapter, we'll learn the basics of unit testing using the practical example.

Goals:

  • Learn how to define the 'unit' to test.
  • Learn the difference between white-box and black-box testing.
  • Learn to recognize and use naming strategies for our tests.
  • Know how to determine when you are 'done' with unit testing.
  • Learn basic best practices
  • Lab: implement unit tests for a simple library.
Test-driven development (TDD)

In this chapter, you will learn what TDD is by example.

Goals:

  • Learn TDD using the red-green-refactor cycle.
  • Lab: Implement a simple library function in a TDD way
Concept of mocking

In this chapter, you will learn what 'mocking' entails and identify where you should use it by identifying your 'system under test' (SUT) and splitting from your 'dependencies'

Goals:

  • Learn to identify the SUT from its dependencies
  • Learn how to write a mock by hand
  • Understand the need for dependency injection when working with mocks.
  • Lab: implement dependency injection and setup mocking using classes.
Code Coverage

In this chapter, we will focus on testing metrics, namely code coverage.

Goals:

  • Know what the difference is between code coverage and mutation testing.
  • Know what kinds of coverage metrics there are and how to choose between them.
  • Learn the benefits of a quick feedback cycle with code coverage.
  • Learn how to run code coverage on our code using the command line.
  • Know how to 'break the build' when coverage is too low.
  • Lab: use code coverage to improve our tests.
Mocking with unittest.mock

In this chapter, you will learn to use a mocking library. We will focus on unittest as an example.

Goals:

  • Learn what monkeypatching is and how to use it.
  • Learn the API of unittest.mock; how to create mocks, configure them using .side_effect and verify behavior using .assert()
  • Lab: Implement your tests using unittest.mock
Testing frameworks

In this chapter, we will focus on the most popular testing framework in python: PyTest

Goals:

  • Know what the benefit is of PyTest
  • Learn how it extends unittest
  • Learn to parameterize our tests.
  • Know what common pitfalls are and how to avoid them.
  • Lab: Improve our test maintainability using features of the testing framework.
Best practices

In this chapter, we will look at some best practices we can use to improve the maintainability of our tests further.

Goals:

  • Know how to identify tests that are too DRY (Don't Repeat Yourself) or too WET (We Like Typing).
  • Learn to prefer DAMP tests (Descriptive and Meaningful Phrases).
  • Know when to use a builder pattern
  • Know where to find more best practices
  • Lab: Implement DAMP tests using the builder pattern.
Mutation testing

In this chapter, we will focus on testing metrics, namely mutation testing.

Goals:

  • Know what the difference is between code coverage and mutation testing
  • Understand how mutation testing works conceptually.
  • Learn what the "mutation score" metric is
  • Learn how to use mutmut to run mutation testing on python code.
  • Know how to read a mutation testing report.
  • Know how to 'break the build' when the mutation score is too low.
  • Lab: Improve the effectiveness of your tests using mutmut.
Integration testing

In this chapter, we'll be 'scaling up the pyramid': Welcome to integration testing.

Goals:

  • Be able to identify where an integration test is needed.
  • Learn to identify 'shared state' in dependencies.
  • Learn how to use TestContainers to create dependencies on the fly.
  • Know what the benefits are of using TestContainers
  • Learn to organize integration tests inside your project structure.
  • Lab: Implement integration tests for a database using TestContainers
Blijf op de hoogte van nieuwe ervaringen
Er zijn nog geen ervaringen.
Deel je ervaring
Heb je ervaring met deze cursus? Deel je ervaring en help anderen kiezen. Als dank voor de moeite doneert Springest € 1,- aan Stichting Edukans.

Er zijn nog geen veelgestelde vragen over dit product. Als je een vraag hebt, neem dan contact op met onze klantenservice.

Download gratis en vrijblijvend de informatiebrochure

(optioneel)
(optioneel)
(optioneel)
(optioneel)
(optioneel)
(optioneel)
(optioneel)

Heb je nog vragen?

(optioneel)

Aanmelden voor nieuwsbrief

We slaan je gegevens op om je via e-mail en evt. telefoon verder te helpen.
Meer info vind je in ons privacybeleid.