|
所在平台: Udemy |
课程主页: https://www.udemy.com/course/pytest-cookbook-using-hooks-to-create-custom-plugins/
课程评论:没有评论
**课程名称:** PyTest Cookbook - 使用钩子创建自定义插件 **课程概述:** 本课程面向 PyTest 中级及以上用户,旨在深入探讨 PyTest 的钩子(hooks)功能,以实现自定义测试行为和生成定制化报告。课程不提供逐行代码演示,而是通过分析和修复现有的代码模板,帮助学员理解 PyTest 钩子的工作原理。 **课程内容亮点:** * **CSV 测试报告生成:** 学习如何利用钩子生成测试执行的 CSV 输出,类似于 `-collect-only` 的功能。 * **动态自定义标记(Markers):** 为测试添加动态标记,以便更有效地管理大量测试。 * **灵活的测试排序:** * 根据测试名称、标记或自定义规则进行排序。 * 随机化测试执行顺序。 * 实现特定标记(如 'first', 'last')的优先执行,并对剩余测试进行自定义排序。 * **动态测试过滤:** 根据自定义标准动态过滤测试。 * **参数化查询的数据加载:** 从代码、数据库或文件中动态加载数据,用于参数化测试。 * **分发式插件创建:** * 学习如何将钩子打包成可分发的 `.whl` 文件,以便于共享。 * 基于自定义排序钩子,实现按字母升序或降序(通过 `-asc` 和 `-desc` CLI 参数)对测试进行排序。 * **美化终端输出:** 使用表情符号、面板和颜色创建引人注目的测试结果控制台输出。 * **学习和定制现有插件:** 查看流行的 PyTest 插件代码,获取灵感和深入理解,并学习如何定制现有插件。 * **保存测试属性:** 学习如何在测试中记录属性,并在最终报告中使用。 **课程方法论:** 课程采用“拆解与修复”的方法,让学员通过实际操作理解代码的运行机制。每项内容都配有详细的注释代码和 Markdown 说明文档,旨在提供一本“电子书”式的学习资源。通过深入讲解代码的“为什么”,并引导学员查阅官方文档获取更多信息,全面提升学员对 PyTest 钩子的掌握能力。 **先修知识:** 本课程要求学员具备 Python 和 PyTest 的中级知识,并熟悉 `pip` 的使用。
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 themI 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!