-1

how to get the current running testcase name in the pytest? please help me out like in the robot framework we can easily take testcase name the same way how to take TC name in pytest?

Ex: My test execution name is "test_retail.py" , if i want to retrieve only the testcase name as "test_retail" how to do it with pytest?

vijaya
  • 1
  • 1

2 Answers2

0

The name of the class inheriting from TestCase? Then it's as simple as:

self.__class__.__name__
JDornheim
  • 91
  • 4
0

Current name of test case can be given by following example:

os.environ.get("PYTEST_CURRENT_TEST")