Pytest - Rules and Features

In the previous post, we've learned about creating the first script using pytest framework. This post will discuss the rules and features

1. Header - All pytest script should include import pytest at header of the script 
2. File naming - pytest only identifies the file names starting with test_ or ending with _test as the test files
3. Method naming - All pytest methods should start with test_
4. Assertions in PyTest - Assertions are used for validating the test conditions. Assertions are checks that return either True or False status. if an assertion fails in a test method, then that method execution is stopped there. The remaining code in that test method is not executed, and pytest will continue with the next test method.
assert "tree" == "tree" is a successful assertion.
assert 10==3 is a assertion failure
assert True is a successful assertion
assert False is an assertion failure.
assert "orange" == "apple" is a assertion failure.
These are basic rules to validate the application with pytest framework. pytest also supports parallel execution, annotation etc, which testodev will cover in the later posts 
Previous Post Next Post