繁体   English   中英

从Python unittest测试套件执行特定测试?

[英]Executing specific tests from Python unittest test suite?

我在测试套件中添加了一些测试用例。 现在,我希望能够执行一些测试,而不会从测试套件中删除任何测试。

在下面的代码中,我在测试套件中添加了三种方法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())

请提出建议。

在要跳过的测试方法上使用注释@unittest.skip

import unittest

@unittest.skip("some comment")
def test_my_function()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM