Tutorial: Visual testing with pytest
If you are like many Python developers out there you LOVE writing code! Tests? Not so much. Whether it’s the concept of testing or the interface of testing tools, testing is a chasm not all developers cross. The Visual Testing with pytest tutorial aims to bring Python testing to the masses, taking a new approach to first contact with Python testing.
Join this journey with us and improve your testing skills in this 9-step tutorial!
As mentioned before, this tutorial was split into 9 steps. The idea is to make each step unique so you can watch and apply your learning as you go. Each tutorial step has a narrated video along with a detailed writeup, connected to working code.
Here’s an overview and below you can find a description for each step.
- Step 1 – Background on Testing: Introduce testing, pytest, and how it all fits into PyCharm, along with a scenario to work on.
- Step 2 – Project Setup: Make a PyCharm project and virtual environment with dependencies, then configure PyCharm to use pytest.
- Step 3 – Hello Test: Write a simple test and run it in PyCharm’s visual test runner.
- Step 4 – Getting Into the TDD Flow: Setup your PyCharm project to help get into the flow of Test-Driven Development (TDD).
- Step 5 – Jump to Error: Writing code means writing broken code. Click a link in a traceback to open a file on the line of the error.
- Step 6 – Skipping Tests: During refactoring, use pytest’s markers to ignore certain breaking tests.
- Step 7 – Test Fixtures: Make your tests more focused by moving sample data to pytest fixtures.
- Step 8 – Debugging During Testing: When writing tests, use the PyCharm “visual debugger” to interactively poke around in the context of a problem.
- Step 9 – Testing Exceptions: Write tests that ensure exceptions are raised when expected.
The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries. For more information about the pytest framework read their official documentation.
About the PyCharm Guide
Looking to level up your Python and PyCharm skills? The PyCharm Guide takes a visual approach, with tips, tutorials, and more.
Subscribe to Blog updates
Thanks, we've got you!
Five Things To Love About the New UI
Are you using the New UI yet? Not yet? Let me tell you why it's the best thing since sliced bread! Let’s get it enabled and take a look around. The easiest way to do that is from the Settings cog at the top-right of the UI: PyCharm will need to restart, but that’s it; you’re done! In t…
Django Custom Tags in PyCharm Professional 2020.1
PyCharm started its life with Django support and our new release adds some useful improvements for Django coding. Let's take a look at support for custom Django tags in PyCharm Professional 2020.1. But First, One More Thing Maybe it's bragging, but we need to show one existing feature related to thi…
Python 3.8 support in PyCharm
The release of Python 3.8 brought new features to the Python coding realm. The language is evolving according to its community's needs by addressing cases where new syntax or logic become necessary. From new ways of assigning expressions to restriction of usage of function declarations, calls, and v…
Jupyter, PyCharm and Pizza
Hi there! Have you tried Jupyter Notebooks integration in PyCharm 2019.2? Not yet? Then let me show you what it looks like! In this blog post, we're going to explore some data using PyCharm and its Jupyter Notebook integration. First, of course, we'll need said data. Whenever I need a new dataset to…