Create the first script using pytest

Hope you're installed pytest package as mentioned in the post. In this post, we're going to create a sample pytest.

As a first step, create a file named test_first.py and copy the below code snippet to it
import pytest
def test_test1():
 a=5
 b=5
 assert a == b,"test failed"
def test_test2():
 x="Cat"
 y="Lion"
 assert x == y,"test failed"
As a second step, using command prompt navigate to the script path and execute below command to run the script
pytest -vv test_first.py -ss
Yes!!!, you've executed the first script and its results are displayed.
Previous Post Next Post