How to generate HTML Report in PyTest Framework

HOME

pip install -U pytest

pip install pytest-html

import pytest


def test_addition():
    a = 6
    b = 5
    c = 11

    assert a + b == 11, "Sum is not 11"
    assert a + b == c, "Sum of a and b is not equal to c"


def test_subtraction():
    x = 15
    y = 4
    z = 10

    assert x - y == z, "Subtract y from x is equal to z"


def test_multiplication():
    a = 6
    b = 5
    c = 30

    assert a * b == c, "Product of 5 and 6 is not 30"


def test_division():
    a = 16
    b = 2
    c = 8

    assert a / b == c, "Division of 2 by 6 is not 3"

pytest --html=report.html

Leave a comment