Hands-On Automated Software Testing In Python (w/ unittest)
What you'll learn
- Analyze existing code bases (& refactor them if needed), and design the needed test cases accordingly.
- Perform automated unit and integration tests on Procedural code and Object Oriented code.
- Learn how to perform Test Driven Development (TDD)
- Perform test coverage and run multiple tests simultaneously.
- Learn how to deal with boiler-plate code and pass-through methods/functions.
- Utilize Pdb (Interactive Python Debugger) on run-time to inspect different test cases.
- Learn how to effectively create mocks and patches, and when to do it based on various case scenarios,
- Know how to fake/sample real-world data.
- Gain a sneak-peak on best practices in OOA, OOD & OOP by implementing UML design schemes from scratch and write tests for the code base you created later on.
- Learn how to deal with files processing and operations (read, write, stdout functions, etc..)
- Fair background in Python is a must.
- Fair background in OOP in Python (specifically classes & object creation, classmethods, staticmethods, getters & setters).
- Fair knowledge in UML class diagrams and it's relationships. (association, aggregation, composition)
- Fair knowledge of Jupyter Notebooks.
Looking for a beginner-friendly, 'getting-started' guide, that happens to ALSO be as comprehensive as possible with rich real-world case scenarios that COMPLETELY covers the all aspects, the ins-and-outs, the nits and grits of Unit and Integration testing Python? Yes dear, you are at the right place.
Welcome to "Hands-On Software Testing in Python" !
If you are a freelancer, a college student, or a software engineer, at some point it's just inevitable to not run atleast some 'exploratory testing' scripts to inspect and test various edge cases, just to make sure how solid your work is, but things starts to go downhill when a certain component breaks down, it's either you go into a refactoring purgatory, or you start the project again from scratch! In this course I will show you multiple case scenarios, where we will have existing code bases, as well as mini-projects that we will build from scratch in a code-along fashion, what matters the most is that we will follow a systematic procedure to analyze and design our test cases, for each case scenario, and then implement them.
My name is Ahmed Alhallag, I'm a Software Engineer and an Assistant Lecturer. I will take you through an intensive journey starting with the theoretical concepts behind Software Testing, up to the inner-most parts where you will learn the best practices in approaching any project, designed and implemented in any paradigm (Procedural & OOP are covered in this course), no matter how large or big it might seem from the surface.
Writing code isn't supposed to be the main point of focus for you as a software developer, especially code that just 'works' for a current point of time. A bunch of other factors needs to be taken into consideration such as:
Quality of modeling:
You might think: "alright, I have this task to implement, so let's just wing it!", and you immediately hop on to your favorite IDE and starting coding. For certain tasks, maybe this would be the time-efficient thing to do, for larger one, this will eventually consume your time on the long run, because you will keep going back in forth in:
encapsulating this block of code, and refactoring that block of code, saving your sensitive data in a .env file after it was thrown away at the top of your script when you started working, serializing this output, and persisting that output into a json file instead of a basic txt file, creating a middleware, an API interface or a certain controller that you suddenly found out that you need to perform some action, implement a data handler because the code became so redundant and intertwined, changing up the entire set of data structures used, which as a result, changes the entire processing logic written ahead of time as well!
See, all of the previous scenarios, are just daily events that we go through in our development journey, if you haven't faced any of them yet, that's good news! We will briefly cover a systematic way to implement our code via analysis (OOA) and design (OOD using UML), with the help of mini-projects that we will build together!
This is obviously not the focus of this course, so we won't be spending much time on that part, we will take we need to get to have a clean code base later on when we implement.
Quality of code:
After the brief concepts on conceptual designs and modeling, we will follow the guides (class diagrams) we created to implement the core system we will test bit by bit later on. We will be using Object Oriented Programming (OOP) for the majority of our implementations.
You might ask yourself, why would we spend THIS much time at the implementation of every use case? why not just take the code as it is and start writing test cases?
That's a valid point, but hear me out: I believe that if your want to know the ins and outs of a system, whether you are performing a defensive/offensive security measure, designing a UI/UX, implementing a database layer, or executing some test cases, you need to be FULLY and THOROUGHLY aware of the system you are working on.
For experienced developers, they can definitely pick the pace off at any point in time and start implementing their test cases, but for anyone who has not written a lot of test cases before, or at the start of their journey, this would be a hassle! not knowing what exactly that needs to be tested, or even not knowing how or where to start!
This is the basis of the approach I'm following in most of the given case scenarios, where basically we will build the end-system we would want to thoroughly test from scratch!
After having a brief on best practices in code/system modeling, and implementing these systems manually, we will dive deep into testing, where:
We will mainly use the unittest framework in Python, which is a built-in easy to use module to get started as quickly as possible.
We will start implementing the mini-project in a Procedural manner (using the most basic modularization approach; functions).
We will then how to design and implement Unit Tests for our procedural code, by setting up our terms of agreement on what exactly should be defined as a "Unit", as well as configuring of new project hierarchy (tree of folders).
We will have a walkthrough into one of the most common approaches used for testing; Test Driven Development, or TDD for short.
We will then have a Paradigm shift, where we travel to the OOP realm. I'm assuming you have a fair background in OOP, a brief recap will be given. (watch the promotional/intro video)
We will write Unit Tests for Object Oriented (classes) that we have created, and an update to our "unit" definition will take place.
We will see how useful your knowledge of the Command Line Interface (CLI) can be, by using your terminal session to inspect and debug your unit tests in real-time using the Python Interactive Debugger.
We will have real data, and we will learn how to sample them and/or fake them when needed
We will design and implement interrelated modules, we will also design and implement the relationships between them. And will know that by doing so, another different added layer/type of testing needs to be performed, which is Integration Testing, to make sure that integrated components, work as intended.
We will see a lot of coupled dependencies, which will lead us to isolate them completely using "Mocking" to perform our unit tests.
We will learn how to deal with intermediary or pass-through code, as it sometimes becomes unclear to whether you should test them or not.
We will learn how to generate test coverage reports (in HTML) and how to run multiple (unit and integration) tests simultaneously.
Finally, we will have an intensive walkthrough on files handlers and operations (such read, write, etc..) as well as the common stdout and stdout functions (such as print, input) and how to exactly test them for full coverage.
Who this course is for:
- Python developers who have some background in Python and want to dive in the software testing world.
- CS/CE students in their first or second year who just got to read about software testing and TDD.
Hello, this is Ahmed!
I noticed a lack of balance in most of the courses that I've personally attended on a lot of platforms, where sometimes you'd find pure practical only, with no theoretical part or sufficient explanation, and sometimes its the other way around.
I usually maintain this balance in my classes, where they get the needed information and theory they need without getting them bored, and jump immediately to technical execution. After thorough planning, I decided to share my experience and knowledge with everyone on the internet, I've been doing this for a while since I started teaching on my YouTube channel, but I decided to take things to the next level, observe actual results with my own eyes from students who follow my content, and give 1-to-1 mentorship to whoever needs it.
I have +6 years of experience in the academic field, I'm currently an Assistant Lecture in Coventry University, Egypt's Branch in TKH (The Knowledge Hub Universities).
I have a BSc in Computer and Communication engineering from Mansoura University. I'm also currently perusing my MSc in Computer Engineering at AASTMT.