Introduction to writing and using (automated) tests

< / / / / / >
Python Framework Testing
V 14.0
+/- 24 minutes
Written by Holden Rehg

Quick scroll

1. Introduction

Welcome to the testing tutorial for Odoo.

What are we going to be dealing with? In this tutorial, we are not going to get into more advanced concepts and ideas around how or what. Those are all things that are debated throughout development communities and that end up being very personal to the types of team or application.

I want to walk through a realistic use-case of a sample module and then show you the process for writing and running some basic tests.

One question you may immediately be thinking is, why should I write tests?

1.1. Testing is usually not new to a programmer

Usually programmers test the code that they've written. It’s something that we most of us are very accustomed to. But many Odoo developers are not taking full advantage of the automated testing tools provided to us by the framework and by the python language.

1.2. Build your own safety net

Writing tests has benefits for most teams, with each team benefiting in different ways. For me, the most important factor is actually not quantifiable. It makes me a less stressed and happier programmer because I know that I’m slowly sowing my own safety net for a project. As each major feature or use case gets a test confirming how it’s expected to work, then that protects me from accidentally deploying broken code. We can’t pull up a large application and manually test all aspects every deployment. Also, as each bug arises a test can be added to confirm that the bug has been resolved and again prevents us from regressing and deploying broken code. In this case, the work kind of broken code being a bug that the client has asked you to fix already.

1.3. Start simple

There are many, many types of tests floating around out there. Then there are also multiple names per type of tests depending on who you are talking to. Integration, unit, functional, etc. You can dig into all of these down the road as you get further into testing. Just start writing tests that replicate the same steps you would take manually.

So I’m going to try to give you all of the tools that you need to get started with testing. In my experience, testing is not as prolific within the Odoo community compared to others, so I’m hoping that this gives a kick start to Odoo developers out there!

You need an account for this tutorial
Create a free account to access the tutorial.

Already a member? login here.