How To Get Currently Running Testcase Name From Testsuite In Unittest
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 adding test to the testSui
Solution 1:
unittest.TestCase.shortDescription()
Returns a description of the test, or None if no description has been provided. The default implementation of this method returns the first line of the test method’s docstring, if available, or None.
Return a string identifying the specific test case. This is usually the full name of the test method, including the module and class name.
Hopefully one of those is useful for your needs.
Solution 2:
unittest.TestCase._testMethodName
Example code:
import unittest
classBasicTests(unittest.TestCase):
deftest_print(self):
print(self._testMethodName)
Post a Comment for "How To Get Currently Running Testcase Name From Testsuite In Unittest"