0

I have added few test cases in my test suite. Now i want to have the ability to execute few tests without removing any test from test suite.

In below code i have added three methods testm1,testm2,testm3 in the testsuite. Now i want to execute say only tests having testm1 and testm3.

Code:

import HTMLTestRunner
import os
import unittest
from test.LoginTest import TestA
from test.LandingTest import TestB


def testsuite():


    execute_suite = unittest.TestSuite()


    execute_suite .addTest(TestA('testm1'))
    execute_suite .addTest(TestB('testm2'))
    execute_suite .addTest(TestB('testm3'))

    return execute_suite 

reportloc = os.getcwd()
outfile = open(reportloc + "TestReport.html", "w")
executor = HTMLTestRunner.HTMLTestRunner(stream=outfile, title="Test Report", description="Tests")


executor.run(testsuite())

Please suggest.

1 Answers1

0

Use annotations @unittest.skip on test method which you want to skip.

import unittest

@unittest.skip("some comment")
def test_my_function()
Akshay
  • 1,231
  • 1
  • 19
  • 31