How to get currently running testcase name from testsuite in unittest

后端 未结 2 1419
一向
一向 2020-12-09 09:02

How can I get currently running testcase name, while in the testsuite collection there are 16 testcases. Tests are executed sequentially (in the order of ad

2条回答
  •  粉色の甜心
    2020-12-09 09:37

    unittest.TestCase._testMethodName

    Example code:

    import unittest
    
    
    class BasicTests(unittest.TestCase):
    
        def test_print(self):
            print(self._testMethodName)
    

提交回复
热议问题