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
Post a Comment