Skip to main content

Python Html Report





Html report using UnitTest and HtmlReporter
 
         pip install html-reports

import pytest

  import unittest

  import HtmlTestRunner

  from HtmlTestRunner import HTMLTestRunner

  import allure

  

  @allure.story('Your Story here')

  @allure.feature('Your Feature here')

  class CodeVlidation(unittest.TestCase):

  

    @classmethod

    def setUpClass(cls):

        print('Executed Before the all the method executed in class')

  

    @classmethod

    def tearDownClass(cls):

        print('xecuted after the all the method executed in class')

  

  

    def setUp(self):

        print("Setup the environment")

    def tearDown(self):

        print("cleaning the environment")

  

    def testcase1(self):

  

        print("running the test case1")

        self.assertEqual(2, 2)

  

    def testcase2(self):

        print("running the test case2")

        self.assertEqual(2, 3)

  

  if __name__ == '__main__':

  

    testList = [CodeVlidation]

    testLoad = unittest.TestLoader()

  

    TestList = []

    for testCase in testList:

        testSuite = testLoad.loadTestsFromTestCase(testCase)

        TestList.append(testSuite)

  

    newSuite = unittest.TestSuite(TestList)

    runner = unittest.TextTestRunner()

    runner=HTMLTestRunner(output='example_dir')

    runner.run(newSuite)




Allure Report using allure and Pytest
install the allure pip install allure-pytest
import pytest
import allure
run from cmd D:\import\UnitTestPython>python -m pytest UnitTest12345.py --alluredir ./results
 D:\import\UnitTestPython>allure serve ./results/







Comments

Popular posts from this blog

API Automation with Python

  SDET API Automation with Python. 1. Installation.        Python ( https://www.python.org/downloads/ )        PyCharm ( https://www.jetbrains.com/pycharm/download/#section=windows )        Create an account on Jira (  https://id.atlassian.com/login ) pip install requests              Create a basic AUTH token for Jira.           echo -n user@example.com:api_token_string | base64 https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/ We will perform get/Post operation on Jira issue. Get issue                GET /rest/api/3/issue/{issueIdOrKey}     https://your-domain.atlassian.com/rest/api/3/issue/{issueIdOrKey}       Using Basic Auth. import requests response=requests.get( 'https://qaclickcenter.atlassian.net/rest/api/3/issue/10001' ,  ...