Skip to content

mitches-got-glitches/testing-tips

Repository files navigation

Testing Tips

View the presentation here.

Parametrisation examples

This repo contains a number of different use cases for parametrising tests as outlined below. For the more complicated ones, they have been committed in several stages so that you're able to view the diffs and make sense of why parametrisation may be beneficial to use in your own tests. Each commit message explains the thinking behind each change. My advice would be to get comfortable with writing normal tests first, before beginning to think about parametrisation.

  1. Simple parametrisation
  2. Parametrising multiple parameters using parametrize_cases
  3. Parametrising a variable number of parameters by making use of kwargs
  4. Using fixtures in parametrisation
  5. Parametrising test cases using slices of dataframes

VS Code Snippets

I've included a JSON file that contains many of the Python snippets I've written to help me with testing. Feel free to copy and adjust to your liking. To add snippets in VS Code, press CTRL + SHIFT + P to open the command palette, type "snippet" and select "Configure User Snippets" which will open the JSON of Python snippets for your user profile. Simply copy the snippets you want across.

A demo on how these work will be added to the presentation in due course.

Other resources

For ONS:

And for those interested...

I used the reveal.js framework for creating the presentation, customising the style using my own CSS file. I used the vscode-reveal extension for a number of useful features that made using reveal.js relatively painless. This included, live preview, live server on a local host, VS Code Reveal tab on toolbar for jumping between slides and easy export. I definitely recommend checking this out for your future presentations.

About

How to write good tests in Python quickly and efficiently.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published