Call-Me-Maybe
Why you might be interested
Lots of people talk about the importance of tests, but its not always easy to implement them in your own code.
I've found that most developers (anyone that has to use a texteditor as part of their job junction) were not introduced to the world of development through the lens of needing to test or maintain code that serves any sort of business function.
A very popular repository on GitHub (over 100k ⭐s!) is @kamranahmedse's developer-roadmap.
How far down the map do you have to go before you get to testing? Is this reflective of your learning experience?
note: I've linked the 'Backend' roadmap, but other roadmaps have a similar journey
Digital Transformation -> means more work for developers
Many companies are currently or planning initiatives to adopt current industry practices, not because they want to use the "new & shiny" but because there's business value provided by adapting technologies and workflows which reduce delivery time.
...but they still want the "new & shiny" i.e. Continous or Automated ...
The NewStack: Why Software Testing Remains A Bottleneck
Frequently this can make even the most minor of changes to an existing code base feeling like...
There's a reason why no one's touched that code in insert unit of time
Types of Testing
You'll hear following words thrown around quite a bit when talking about testing... and they can mean very different things depending on the context they're used.
- unit
- functional
- integration
- end-to-end
- perfomance
- regression
- ...
- ...
- ...
- ...
- ...
For example, a unit test might mean something slightly different between developers who use live in different ecosystems (Python vs Java). What about between Data Scientists, SysAdmins, or Network Engineers.
- This may vary depending on what you're working on:
- jupyter notebook
- web application
- cli tool
- serverless function
- library/package
- Code Structure
- Scope
It can feel a little bit like Calvinball at times 🙃.
Testing Pyramid
One of the better talks I've come across with breaking down defintions not only across a language but across an Application's entire development lifecycle.
One of the best talks about testing (infrastructure) but principles can be applied generically.
Automated Testing for Terraform, Docker, Packer, Kuberernetes, More
Static Analyis
"Look at my code, don't run it, tell me if there's a bug or if there's some sort of issue."
Linters
- Flake8
- Pylint
- Pyflakes
Formatters
- Black ⭐
- isort
Types
- MyPy
- Pydantic
- Marshmallow
Code Coverage
- Coverage.py
Security
- Bandit
Git
- pre-commit
- gitlint
Unit Testing
Whats a unit?
it depends...
Demo Time. What are the units in the demo app provided?
Pytest
IMHO the best python testing framework out there right now.
Lab
Install pytest
$ python3 -m pip install --upgrade pip
$ python3 -m venv .venv
$ source .venv/bin/activate
# windows script path?
Verify
$ pytest -v