Main advantage: learning how to maintain code, especially when introducing new changes is slow and you get a lot of bugs with every change. Your developers will start test their code or they’ll do it much better than before after this course. This will speed up your team and they’ll introduce less bugs with each change.
Duration: 3 days x 7 hours brutto (i.e. including breaks) + consultations after every course day
Format: workshop (70% workshop / 30% lecture)
Venue: client’s office or other place chosen by the client, in Europe
Enrollment: in-house on-site course for a group of people within one company
Group size: max 10 delegates
Course language: English or Polish or both during the same training
Audience: manual and automatic testers, developers
Audience requirements: basic programming skills. No need for previous Python, testing or TDD experience.
I. SOLID Principles
We start from a discussion on SOLID principles that makes code easier to read and maintain. This part is supplemented with exercises showing how to apply (and how not to do this) SOLID in Python. This will be helpful in the second step of each iteration in TDD (as well as BDD), that is writing production code.
II. Code Refactoring
The third step of each iteration in both TDD and BDD is refactoring, that is making code easier to read and maintain without changing its functionality.
In this part, we cover all building blocks (or actions) of refactoring. We introduce the concept of code bad smells that help you find opportunities for correct refactoring and avoid “endless refactoring back and forth”.
III. Builtin Testing Frameworks
First step of each iteration in TDD is writing a test.
We start from a discussion if and why writing tests is beneficial. Contrary to intuition, less bugs is only one of the advantages of covering code with tests.
We usually use a framework that makes writing tests easier. We show how to use the most popular testing framework – unittest.
We also introduce very agile doctest library which help you test, and at the same time, document small utility functions without all the burden and long-winded unittest.
IV. Test Driven Development
After short theoretical introduction to TDD, we solve Katas – programming challenges like RecentlyUsedList or BowlingGame. Katas are simple exercises that let you focus on the TDD methodology rather than fighting with language, IDE or business logic.
We start from a live coding – the instructor shows how you can solve a Kata using TDD. Participants ask questions and discuss with the instructor and other participants. Later on, we move to another Kata. This time participants do the exercise in pairs (pair programming).
V. Test Isolation and Mocking
Test isolation and mocking is covered during second day of the training. We introduce great unittest.mock builtin library (or mock backport if you work on Python 2). It helps you isolate your tests from system calls, filesystem, databases, external APIs or any other resources. We study the most common cases.
Mocking is also an essential part of outside-in development which is covered during the last day.
VI. Testing Web Applications
Testing Web Application let you focus on one of common cases when you need to test a web application written using a framework. For simplicity, this framework is Flask unless you work in Django, in which case we focus on Django’s own challenges.
A number of tools are discussed, Selenium and builtin Flask client being two of them. However, we introduce and focus on WebTest which is other client and is much faster than Selenium.
VII. Overview of Other Testing Approaches and Code Coverage
At the end of the second day, the instructor introduces other testing approaches. We discuss property-based testing (with hypothesis-python library) and mutation testing (with MutPy). We also introduce a concept of code coverage and show how to configure it.
VIII. Outside-in Development
Most of the time, programmers develop their code inside-out. They start from the simplest functions and tools (inner or lower modules), maybe even they test them, and built outer (or higher) modules upon them. For example, they first implement backend, and then frontend. This is dictated by the fact that the outer modules depend on the lower ones, for example frontend depends on backend. Therefore, you cannot test outer ones without inner ones.
However, this results in bad interfaces, because outer modules are written to match inner modules instead of required behavior. Outside-in development forces you to first implement higher modules, test them mocking the lower modules, and then focus on the inner modules. This results in better interfaces between modules.
IX. Plain-Text Stories in Gherkin
We introduce a special domain specific-language based on English natural language that helps you write acceptance tests understandable for non-programmers. If you have ever heard about Cucumber, you’ll be astonished that there is a very similar framework in Python called behave.
X. nose2.tools.such DSL
We introduce another style of BDD – executable specification written with nose2.tools.such plugin, a DSL in Python.
We also introduce nose2 tool to run unit tests and show how you configure it and enable nose2.tools.such plugin.
XI. Behaviour Driven Development
Behave Driven Development is an extension of TDD. After a short theoretical introduction, we show on a case study how you can use behave and nose2.tools.such with BDD. We also show how professional edition of PyCharm supports BDD and behave framework.
Benefits for the Sponsor
As the course sponsor or HR you get:
- Analysis of the needs and my help to choose or design a great course during a phone call with the sponsor, HR, team leader or/and course delegates. On top of that, we ask delegates on the very first day what their needs are, to make even better usage of the course time.
- Course customisation to your needs.
- Guarantee that the course is conducted by an expert that worked for Google.
- Course evaluation as an electronic form at the end of the last course day. The evaluation results are sent to interested people (most of often they’re course sponsor and HR).
- Simple communication – you can contact the trainer directly by phone or email.
- Easy buying procedure – one call or email is enough to get offer and to book a date. I don’t do overbooking. The course is confirmed once you send the Purchase Order.
- Friendly business partner – as a rule, I treat all my clients like friends. I don’t build walls, I’m not pretending to be a huge training company and I write in first person.
Clients very often decide to order other training (including dedicated courses) after observing positive results of this course.
Benefits for Delegates
Delegates will benefit because of:
- Seven hours course every day (including breaks)
- Consultations after every course day.
- Support after the course, via email and phone.
- Setup instruction before the course to save time at the beginning of the course. I’m happy to help you via email, phone or Skype, zoom.us etc. in case of any questions or issues.
- Course materials consisting of code snippets, comments, exercises and solutions. The entire courseware is a single web page which make it very easy to lookup something there. Courseware is available online during and after the training. Delegates can download it to use it offline. Courseware can be updated during the course in real time, so that we can include comments or entire new sections suggested by delegates.
- Environment ready to use after the course – we don’t use virtual machines. Instead, we install everything on delegates machines, so that they can reuse the same setup after the course.
Below you can find some references.
Very inspiring training. I really appreciate the way Chris managed to walk us through the complex world of machine learning using Python. Good course materials updated real time. Highly recommend.
Finance Director at DNB Bank Polska S.A.
Well prepared training and reasonably passed knowledge, thanks to which we develop better services.
Infrastructure Team Manager at allegro.pl
Chris recently taught a four day class on Machine Learning with Python four our team. The class was very good with the right balance of theory and practice. I cannot think of a better way to give a four day class about such an extensive topic.
Head of Krakow Product Control Analytics at HSBC
You can read more references here.