-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can not set custom test method name when using data provider #3121
Comments
This is supposed to work and it is covered by a test: https://github.com/testng-team/testng/blob/master/testng-core/src/test/java/test/name/ITestSample.java Could you try with a |
That sounds more like a reporter issue. We need to check. |
@motivatedmind - Quick question. Have you ever seen this work in TestNG? I ask because this has been like this for over 6 years now. Please see here |
@motivatedmind Also please can you point me to any place where there's a reference of this expectation. Just trying to ensure that if we deviated from a documented behaviour then we know about where its mentioned so in the documentation, so that when we fix the problem, we can point people to the documentation source, as a reason why the behaviour was changed. |
@krmahadevan I am not aware if this has worked. But when I was looking for solutions on the internet, I saw people suggesting implementing ITest to achieve this. |
@krmahadevan Again I am not aware of reference. However in case of data provider same method is getting iterated over different data. So having same method name would make it difficult to understand which data the test failed for. It really puzzles me how people are handling this currently probably third party plugins like allure, extent etc. But at this point I am only looking basic report. It would be great if this gets fixed. Alternately is there is any work around to get going? |
@motivatedmind - The emailable report that you are referring to, was never enhanced to make it aware of this capability. But if you look at the report, you would notice that each of the methods are hyper links and when clicked they will take you to the section that contains the details of the parameter. See below screenshot. Would that help ? Ideally speaking the ITest implementation IMO was meant to be used with factory powered test classes, because there would be many instances. I dont think it was meant to work properly with a data driven test. The TestNG provided reports are pretty basic and perhaps don't have all the bells and whistles in terms of features. It would be good to adopt some of the 3rd party reports for reporting purposes or maybe use https://github.com/testng-team/reportng |
@krmahadevan I noticed that test method names are hyperlinks, and they take me to actual test case. But just that for non-technical users it sounds little confusing hence I am looking to change to custom name. Also, I tried to alter name using reflection (I am not sure if this is right way). It works well in case of distinct test methods as below. I can also see custom name in index.html. But it doesn't work with single test method + data provider.
Is there any further workaround I can do just so the names are fixed. |
@motivatedmind - Easiest would be for you to build your own reporting implementation (either from the scratch or you can extend the |
@motivatedmind - You would need to be changing that part, wherein instead of trying to alter the name of the test method from within your test/configuration, you basically construct the test method name using whatever parameters. So in a nutshell, you would be doing:
|
TestNG Version
7.10.2
Expected behavior
I should be able use a value from data provider and use it as a custom test name
Actual behavior
The Test method name appears in emailable report but not the custom name
Is the issue reproducible on runner?
Yes
Test case sample
Emailable report:
Contribution guidelines
Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.
The text was updated successfully, but these errors were encountered: