I came across these articles about pytest recently and thought they might be of interest to other developers here.
These slides start basic, but cover a lot of ground and I learned a lot: https://nedbatchelder.com/text/test3.html Not the main thrust of the presentation, but one quote I liked: "The kind of change I’m talking about here is refactoring your product code so that your tests can get at the parts they want to. There’s nothing wrong with using your testing as a way to challenge the modularity of your code. Usually, improving the structure to benefit tests also ends up helping you in other ways." Another quote I found useful. Based on this explanation, I changed some tests I happened to be writing at the time (i.e moving more code out from the test and into fixtures). Having the error vs. failure distinction is useful in troubleshooting failed tests: "Exceptions in the fixtures are counted as Errors, whereas exceptions in the test function are Failures. This is a subtle but important distinction. A Failure means the test ran, and detected a problem in the product code. An Error means we couldn’t run the test properly. This distinction is one reason to put set-up code in fixtures, but there are others as we’ll see." The below two were linked from the above presentation: https://salmonmode.github.io/2019/03/29/building-good-tests.html This article also had some snips related to the quotes I already pasted above (emphasis mine): "Testing code should not be difficult. *If the code is hard to test, then the code is hard to use*. This is also indicative of tightly coupled code." "Steps in the setup process can be broken out into standalone fixtures that should throw errors if something didn’t go well. When those errors are thrown, they will show up as an error in the test report, rather than a failure in the test itself. When a test has an error, it should represent that the desired state for that test could not be reached. If a test fails, it should represent that the state was reached, but something about the state is wrong" https://github.com/okken/pycascades2020 - Multiply your Testing Effectiveness with Parametrized Testing I haven't gone through this one as thoroughly, but it also seems pretty good. Brian -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAO5X8CzCmrC5qJuDSXSfFXLDjhOhSHvYTp%3DEuw6ZDa4gAGFGng%40mail.gmail.com.