
Who I am. A developer/tester who also studies courses and needs to learn new technologies. I teach very much as developer to develop, sharing what has helped me as well as acknowledging all that it 'does not get any easier - just different!
The course is designed to be modular so that each section is self contained. You can start any where you like and references to early are made where possible.
The repo contains all the completed and highly-commented code as well as useful resources. acting as a sort pf 'ebook' as well as code reference.
I always learn new things about VS Code and setup from courses so I run through my set up so you can reproduce it if you wish or learn some new tips.
We look at how logging is done in PyTest, the location and name of log file as well as the format of the log messages.
We can pas in our own command line arguments using the pytest_addoption hook. We introduce this hook here and we will use this in Project 02.
We will refresh ourselves with markers and how the --strict-markers option works.
We will look at where hooks are stored and what we mean by making a plugin - local or distributable.
We will also see how many hooks of the same type are handled.
We look at the contents of this project.
We look at what happens if we turn on/off --strict-markers in pytest.ini along with having markers registered or not.
We can create and add markers dynamically based on code. This means we can carry out test suite organisation and management programmatically to save time, effort and errors.
We will now run the tests using the -m 'simple_marker' etc to check we get the corresponding selected tests only.
We will look at how naming our tests can help us in creating more functionality with our hooks as well as how markers can help.
We look at a real world case where someone wants a report of all tests we will be running - effectively our report of --collect-only rather than viewing this in the console.
We have a demo look at the three types of sorting - by test name, by makers and randomly.
We create the option to pass in two CLI flags --desc and --asc. If passed in, we sort al our tests by testname, either asc or desc or not at all depending on which flag, if any, has been passed in.
Once again we use the pytest_collection_modifyitems hook to mange the order of the tests.
We can group our tests based on two custom markers - first and last. Tests will then be run in the order - first, others, last.
Splitting tests based on whether they have the 'first', 'last' or no markers and ordering them first-others-last.
We look at why we need to add markers dynamically to avoid any future warnings or errors based on pytest.ini setting.
We can use the pytest_collection_modifyitems to gather all our tests into a list. We can then shuffle this list using random.shuffle(tests). We can apply more complex randomising algorithms by using the techniques we have seen previously of grouping our tests and then randomising within these groups and then randomising the groups themselves.
We take a quick look at another randomising alogorithm used in pytest-random-order
A refresher on what a nodeid is.
We look at the hook's code to see how we separate tests into 'select' and 'deslected'.
We look at a standard example of parametrized tests where we can test multiple data examples.
Using the pytest_addoption hook, we can pass in CLI arguments to customise our test run.
Using the pytest_addoption hook, we can pass in CLI arguments to reference a file with data.
We summarise what we have learnt in this section.
We can use this hook to load configuration values for our test run. We also look at the config object's contents.
In this course, we explore PyTest hooks so that we can modify our tests as well as create our own report files.
This is an intermediate and above course.
There is no code along but we work on completed templates, breaking and fixing to understand how they work.
We will learn to use hooks to:
Create a CSV output of teststhat will be run (like --collect-only). Project 01)
Add custom markers to tests dynamically to enable management of a large number of tests. (Project 02)
Order tests by name, markers and custom criteria. (Project 03)
Randomise order of tests. (Project 03)
Sort tests to run those with markers 'first' first, those with markers 'last, and the rest in the middle with a custom ordering, (Project 03)
Filter tests based on custom criteria dynamically. (Project 04)
Enable dynamic loading of data from code, database or files for parametrized queries. (Project 05)
Create distributable .whl (wheel) files to share your plugin in many ways using one of our custom sorting hooks that sorts test by test name alphabetically in asc or desc with the use of --asc and --desc CLI flags that we built in Project 03.
Learn now to view popular plugin code to get ideas and understanding. We can learn a lot as well as customise already made plugins.
Save properties recorded in tests for use in our final report. (Project 06 and 07)
Create stunning test result console output with emojis, panels and colours! (Project 08)
Learn now to view popular plugin code to get ideas and understanding. We can learn a lot as well as customise already made plugins.
Create distributable plugins:
Create distributable .whl (wheel) files to share your plugin in many ways using one of our custom sorting hooks that sorts test by test name alphabetically in asc or desc with the use of --desc CLI flag that we built in Project 02.
This course assumes intermediate knowledge of Python and PyTest and the use of pip installations. It is not a beginner's course.
There are many hooks or entry points when we run PyTest and by using these we can modify how PyTest runs.
We will learn how to package our hooks into distributable plugins that can be uploaded to PyPi or distributed as .whl files.
Please note!
I do not do a code along.
There are advantages to this and I myself do like following videos with this style.
However, for speed and efficiency, I provide all the source code so we can focus on understanding why the code works rather than just getting it to work.
Methodology:
We will break and fix the code so that we can see what is happening and it also means you will have ready made plugins to modify to your own requirements.
We will go though the 'whys?' of the code and learn how use the docs to get more information.
Each project has written notes to help understand and use them and you will have ready made plugins to go! All you need to do is modify them and use them
I have really enjoyed researching and developing this course and is the course I have wanted.
Complete final source code that is highly commented along with markdown notes to provide an 'ebook'.
Let's start building plugins and leverage the power of PyTest!