{"action":"closed","issue":{"url":"https://api.github.com/repos/cbeust/testng/issues/1756","repository_url":"https://api.github.com/repos/cbeust/testng","labels_url":"https://api.github.com/repos/cbeust/testng/issues/1756/labels{/name}","comments_url":"https://api.github.com/repos/cbeust/testng/issues/1756/comments","events_url":"https://api.github.com/repos/cbeust/testng/issues/1756/events","html_url":"https://github.com/cbeust/testng/issues/1756","id":312794331,"number":1756,"title":"ITest .getTestName() doesn't return the actual test name for skipped methods","user":{"login":"krmahadevan","id":909773,"avatar_url":"https://avatars0.githubusercontent.com/u/909773?v=4","gravatar_id":"","url":"https://api.github.com/users/krmahadevan","html_url":"https://github.com/krmahadevan","followers_url":"https://api.github.com/users/krmahadevan/followers","following_url":"https://api.github.com/users/krmahadevan/following{/other_user}","gists_url":"https://api.github.com/users/krmahadevan/gists{/gist_id}","starred_url":"https://api.github.com/users/krmahadevan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krmahadevan/subscriptions","organizations_url":"https://api.github.com/users/krmahadevan/orgs","repos_url":"https://api.github.com/users/krmahadevan/repos","events_url":"https://api.github.com/users/krmahadevan/events{/privacy}","received_events_url":"https://api.github.com/users/krmahadevan/received_events","type":"User","site_admin":false},"labels":[{"id":467597970,"url":"https://api.github.com/repos/cbeust/testng/labels/Feature:%20skip%20test","name":"Feature: skip test","color":"0e8a16","default":false}],"state":"closed","locked":false,"assignee":{"login":"krmahadevan","id":909773,"avatar_url":"https://avatars0.githubusercontent.com/u/909773?v=4","gravatar_id":"","url":"https://api.github.com/users/krmahadevan","html_url":"https://github.com/krmahadevan","followers_url":"https://api.github.com/users/krmahadevan/followers","following_url":"https://api.github.com/users/krmahadevan/following{/other_user}","gists_url":"https://api.github.com/users/krmahadevan/gists{/gist_id}","starred_url":"https://api.github.com/users/krmahadevan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krmahadevan/subscriptions","organizations_url":"https://api.github.com/users/krmahadevan/orgs","repos_url":"https://api.github.com/users/krmahadevan/repos","events_url":"https://api.github.com/users/krmahadevan/events{/privacy}","received_events_url":"https://api.github.com/users/krmahadevan/received_events","type":"User","site_admin":false},"assignees":[{"login":"krmahadevan","id":909773,"avatar_url":"https://avatars0.githubusercontent.com/u/909773?v=4","gravatar_id":"","url":"https://api.github.com/users/krmahadevan","html_url":"https://github.com/krmahadevan","followers_url":"https://api.github.com/users/krmahadevan/followers","following_url":"https://api.github.com/users/krmahadevan/following{/other_user}","gists_url":"https://api.github.com/users/krmahadevan/gists{/gist_id}","starred_url":"https://api.github.com/users/krmahadevan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krmahadevan/subscriptions","organizations_url":"https://api.github.com/users/krmahadevan/orgs","repos_url":"https://api.github.com/users/krmahadevan/repos","events_url":"https://api.github.com/users/krmahadevan/events{/privacy}","received_events_url":"https://api.github.com/users/krmahadevan/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-04-10T06:54:12Z","updated_at":"2018-04-10T17:17:32Z","closed_at":"2018-04-10T17:17:32Z","author_association":"COLLABORATOR","body":"### TestNG Version\r\n> Note: only the latest version is supported\r\n\r\n6.14.3\r\n\r\n### Expected behavior\r\n\r\nIf a test class has implemented `org.testng.ITest` then TestNG should be invoking `getTestName()` for skipped tests.\r\n\r\n### Actual behavior\r\n\r\nCurrently TestNG ends up retrieving just the actual method name instead of invoking `getTestName()` for skipped tests.\r\n\r\n### Is the issue reproductible on runner?\r\n\r\n- [X] Shell\r\n- [X] Maven\r\n- [X] Gradle\r\n- [ ] Ant\r\n- [ ] Eclipse\r\n- [ ] IntelliJ\r\n- [ ] NetBeans\r\n\r\n\r\n### Test case sample\r\n> Please, share the test case (as small as possible) which shows the issue\r\n\r\nBelow snipped can be used to reproduce the problem.\r\n\r\n**Test class**\r\n\r\n```java\r\nimport org.testng.ITest;\r\nimport org.testng.annotations.Listeners;\r\nimport org.testng.annotations.Test;\r\n\r\nimport java.util.UUID;\r\n\r\n@Listeners(CustomTestNGReporter.class)\r\npublic class BaseTest implements ITest {\r\n    private static String uuid = UUID.randomUUID().toString();\r\n\r\n    public static String getUuid() {\r\n        return uuid;\r\n    }\r\n\r\n    private String uri;\r\n\r\n    public BaseTest() {\r\n        this.uri = uuid;\r\n        System.err.println(\"uri at the time of object creation \" + uri);\r\n    }\r\n\r\n\r\n    @Test\r\n    public void test1() {\r\n        throw new RuntimeException(\"failed\");\r\n    }\r\n\r\n\r\n    @Test(dependsOnMethods = \"test1\")\r\n    public void test2() { }\r\n\r\n    public String getTestName() {\r\n        return uri;\r\n    }\r\n}\r\n```\r\n\r\n**Listener**\r\n```java\r\nimport org.testng.IReporter;\r\nimport org.testng.IResultMap;\r\nimport org.testng.ISuite;\r\nimport org.testng.ITestContext;\r\nimport org.testng.xml.XmlSuite;\r\n\r\nimport java.util.LinkedList;\r\nimport java.util.List;\r\n\r\npublic class CustomTestNGReporter implements IReporter {\r\n    private List<String> logs = new LinkedList<>();\r\n\r\n    public List<String> getLogs() {\r\n        return logs;\r\n    }\r\n\r\n    public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {\r\n        getTestMehodSummary(suites);\r\n    }\r\n\r\n    private void getTestMehodSummary(List<ISuite> suites) {\r\n        suites.forEach(iSuite -> iSuite.getResults().values().forEach(each -> {\r\n            ITestContext testObj = each.getTestContext();\r\n            System.err.println(\"Getting failed test method related data\");\r\n            getTestMethodReport(testObj.getFailedTests());\r\n            System.err.println(\"Getting skipped test method related data\");\r\n            getTestMethodReport(testObj.getSkippedTests());\r\n            System.err.println(\"Getting passed test method related data\");\r\n            getTestMethodReport(testObj.getPassedTests());\r\n\r\n        }));\r\n    }\r\n\r\n    private void getTestMethodReport(IResultMap testResultMap) {\r\n        testResultMap.getAllResults().forEach(iTestResult -> logs.add(iTestResult.getName()));\r\n    }\r\n}\r\n```\r\n\r\n**Test runner class**\r\n```java\r\nimport org.assertj.core.api.Assertions;\r\nimport org.testng.ITestNGListener;\r\nimport org.testng.TestNG;\r\nimport org.testng.annotations.Test;\r\n\r\npublic class TestRunner {\r\n    @Test\r\n    public void testMethod() {\r\n        TestNG testng = new TestNG();\r\n        testng.setTestClasses(new Class[] {BaseTest.class});\r\n        CustomTestNGReporter reporter = new CustomTestNGReporter();\r\n        testng.addListener((ITestNGListener) reporter);\r\n        testng.run();\r\n        System.err.println(reporter.getLogs());\r\n        Assertions.assertThat(reporter.getLogs()).containsExactly(BaseTest.getUuid(), BaseTest.getUuid());\r\n    }\r\n}\r\n```\r\nThis test currently fails with the below output:\r\n\r\n```\r\nuri at the time of object creation 10871d39-1691-47b8-905f-5d244aa99f7a\r\n\r\n===============================================\r\nCommand line suite\r\nTotal tests run: 2, Failures: 1, Skips: 1\r\n===============================================\r\n\r\nGetting failed test method related data\r\nGetting skipped test method related data\r\nGetting passed test method related data\r\n[10871d39-1691-47b8-905f-5d244aa99f7a, test2]\r\n\r\njava.lang.AssertionError: \r\nExpecting:\r\n  <[\"10871d39-1691-47b8-905f-5d244aa99f7a\", \"test2\"]>\r\nto contain exactly (and in same order):\r\n  <[\"10871d39-1691-47b8-905f-5d244aa99f7a\",\r\n    \"10871d39-1691-47b8-905f-5d244aa99f7a\"]>\r\nbut some elements were not found:\r\n  <[]>\r\nand others were not expected:\r\n  <[\"test2\"]>\r\n\r\n\r\n\tat com.rationaleemotions.stackoverflow.qn49693956.TestRunner.testMethod(TestRunner.java:17)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)\r\n\tat org.testng.internal.Invoker.invokeMethod(Invoker.java:583)\r\n\tat org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)\r\n\tat org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)\r\n\tat org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)\r\n\tat org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)\r\n\tat org.testng.TestRunner.privateRun(TestRunner.java:648)\r\n\tat org.testng.TestRunner.run(TestRunner.java:505)\r\n\tat org.testng.SuiteRunner.runTest(SuiteRunner.java:455)\r\n\tat org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)\r\n\tat org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)\r\n\tat org.testng.SuiteRunner.run(SuiteRunner.java:364)\r\n\tat org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)\r\n\tat org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)\r\n\tat org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)\r\n\tat org.testng.TestNG.runSuitesLocally(TestNG.java:1137)\r\n\tat org.testng.TestNG.runSuites(TestNG.java:1049)\r\n\tat org.testng.TestNG.run(TestNG.java:1017)\r\n\tat org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)\r\n\tat org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)\r\n\r\n\r\n===============================================\r\nDefault Suite\r\nTotal tests run: 1, Failures: 1, Skips: 0\r\n===============================================\r\n```"}}
{"actor":{"display_login":"cbeust"}}