0
我在测试套件中添加了一些测试用例。现在我想有能力执行一些测试,而无需从测试套件中删除任何测试。从Python unittest测试套件执行特定测试?
在下面的代码中,我在testsuite中添加了三个方法testm1,testm2,testm3。 现在我想执行只说testm1和testm3的测试。
代码:
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())
请建议。
请发布您的代码,以便人们可以帮助您。您可以查看http://stackoverflow.com/questions/15971735/running-single-test-from-unittest-testcase-via-command-line –
不清楚你在问什么 – Shaun
编辑的问题。 – RakeshKirola