Validation / Testing / Quality Assurance Overview

The Problem

You have a dashboard that is supposed to work. You even know that it runs, or at least starts. But how do you know that it works correctly?

Let’s bring back the cake analogy. It may be hard to tell if the cake is tasty and your SO will like it. But you can make some basic checks:

  • Did you put all the ingredients in?
  • Did you bake it for the right amount of time?
  • Does it look like a cake (more or less)?
  • Did it pass the toothpick test?
  • Did it even fit in the oven?
  • Did you even turn the oven on?
  • Did you even put the cake in the oven?

As you can see, even children can do some basic checks, no cooking/tasting experience required.

Some of those checks are more basic, some are more advanced. You could say that some overlap with each other. For example, the cake can’t pass the toothpick test if you didn’t put it in the oven. It’s a waste of time (💸💸💸) to send your cake (dashboard) to the professional taster (tester/QA team) without performing those checks.

The Solution

The same goes for the code. While it can be hard to tell if the dashboard is working correctly, you can make some checks:

  • Does the dashboard start?
  • Is there a table with the data at all?
  • When you click on the button, does the table change, at all?
  • When you click on the button, does the table change as expected?

Or even the more basic ones:

  • Does my add function add two numbers correctly?
  • Does my filter function filter the data correctly?

Sometimes not all of those checks are possible, for example you don’t have access to the production data, but you can still do some basic checks.

The first group is called end-to-end tests and the second group is called unit tests. There are many more types of tests, but we tend to focus on those two in shiny apps. What’s important, testing frameworks allow you to automate those checks, so you don’t have to do them manually every time you make a change. Only after all checks are passed, you send your dashboard to the dedicated QA team.

Important

Testing your application saves you time and money, by involving the QA team only when necessary.

Tapyr comes with a pre-configured setup that will make testing much simpler and more efficient.

Why good code is the tested code

Tests are another layer of the safety net for your code. First you catch errors with the linter, then with type checking, then with tests.

You catch many errors before they reach the production, before they reach the QA team.

But there is more to it. There’s surprising correlation between the testability of the code and its quality, maintainability and understandability. If your code is tested, it’s easier to make changes to it, because you can be sure that you didn’t break anything.

Check the Unit Testing and End-to-End Testing sections to learn how to write and run tests.

Spoiler alert: you can run all of them with simple pytest command in the terminal!