What Are pytest Fixture Scopes and Teardown with yield?
Choose the right pytest fixture scope for speed and isolation, and clean up resources reliably with yield, finalizers and transaction rollbacks.
48 posts about Software Testing: questions with answers, tutorials and articles, newest first.
Choose the right pytest fixture scope for speed and isolation, and clean up resources reliably with yield, finalizers and transaction rollbacks.
Fixtures are reusable setup functions that pytest injects into tests by name. Learn how to define them, combine them and use the built-in ones.
See which files, functions and classes pytest collects by default, how to change the rules, and how assert rewriting produces detailed failure messages.
Install pytest, write a first test with a plain assert, check exceptions with pytest.raises and learn the command line options for running tests.
Add tests to untested code without rewriting it: pin current behaviour, create seams to cut dependencies, and grow coverage where changes happen.
Code coverage shows which code your tests run, not how well they check it. Learn line vs branch coverage, a sensible target percentage and how to enforce it in CI.
A stub returns canned answers, a mock verifies calls, a fake is a simple working version and a spy records usage. See Python examples and learn when to use each.
BDD describes software behaviour as Given-When-Then examples everyone on the team can read. Learn Gherkin syntax, pytest-bdd automation and how BDD differs from TDD.
TDD means writing a failing test first, making it pass with minimal code, then refactoring. Follow a worked pytest example and learn the benefits and limits.
A good unit test name states the behaviour, the condition and the expected result. See the common naming patterns with examples in Python, Java and JavaScript.
FIRST stands for Fast, Isolated, Repeatable, Self-validating and Timely. Learn what each principle means and how to apply it to your unit tests with pytest examples.
Learn the Arrange-Act-Assert pattern with a pytest example, why it keeps unit tests readable, and the common mistakes to avoid.
Learn what unit testing is, see a complete pytest example and understand why unit tests find bugs early and make refactoring safe.
Learn what regression testing is, its main types, and how to select, prioritise and automate regression tests for each release.
Compare smoke testing and sanity testing by purpose, scope and timing, with examples and a simple release workflow.
Understand the defect life cycle: the states from New to Closed, special outcomes like Rejected and Reopened, and a sample workflow.
Learn the difference between severity and priority of a defect, who sets each one and four real combinations with examples.
A clear bug report lets a developer reproduce the defect without questions. See the fields, a step-by-step method, severity versus priority and an example.
An RTM links each requirement to its test cases and defects, showing coverage and gaps. Learn the types, a build process and a worked example.
A test scenario is a high-level what, a test case is a detailed how with data and expected results. Compare them with examples and an interview-ready answer.