{"action":"created","issue":{"url":"https://api.github.com/repos/cbeust/testng/issues/1444","repository_url":"https://api.github.com/repos/cbeust/testng","labels_url":"https://api.github.com/repos/cbeust/testng/issues/1444/labels{/name}","comments_url":"https://api.github.com/repos/cbeust/testng/issues/1444/comments","events_url":"https://api.github.com/repos/cbeust/testng/issues/1444/events","html_url":"https://github.com/cbeust/testng/issues/1444","id":233502443,"number":1444,"title":"Retry mechanism will not work when the beforemethod/aftermethod got exception,","user":{"login":"fionazj","id":4523962,"avatar_url":"https://avatars2.githubusercontent.com/u/4523962?v=4","gravatar_id":"","url":"https://api.github.com/users/fionazj","html_url":"https://github.com/fionazj","followers_url":"https://api.github.com/users/fionazj/followers","following_url":"https://api.github.com/users/fionazj/following{/other_user}","gists_url":"https://api.github.com/users/fionazj/gists{/gist_id}","starred_url":"https://api.github.com/users/fionazj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fionazj/subscriptions","organizations_url":"https://api.github.com/users/fionazj/orgs","repos_url":"https://api.github.com/users/fionazj/repos","events_url":"https://api.github.com/users/fionazj/events{/privacy}","received_events_url":"https://api.github.com/users/fionazj/received_events","type":"User","site_admin":false},"labels":[{"id":218878480,"url":"https://api.github.com/repos/cbeust/testng/labels/Feature:%20before/after","name":"Feature: before/after","color":"0e8a16","default":false},{"id":209474267,"url":"https://api.github.com/repos/cbeust/testng/labels/Feature:%20retry-analyzer","name":"Feature: retry-analyzer","color":"0e8a16","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-06-05T06:09:36Z","updated_at":"2018-02-14T18:02:22Z","closed_at":"2017-06-06T03:11:04Z","author_association":"NONE","body":"### TestNG Version\r\n> Note: only the latest version is supported\r\nTestNG 6.11\r\n### Expected behavior\r\nRetry mechanism is still working.\r\n\r\n### Actual behavior\r\nRetry is not working.\r\n\r\n### Is the issue reproductible on runner?\r\n\r\n- [ ] Shell\r\n- [ ] Maven\r\n- [ ] Gradle\r\n- [ ] Ant\r\n- [x] 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\nRetryAnnotationListener \r\n```\r\n\r\npublic class RetryAnnotationListener implements IAnnotationTransformer {\r\n  @Override\r\n  public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor,\r\n      Method testMethod) {\r\n    IRetryAnalyzer retry = annotation.getRetryAnalyzer();\r\n    if (retry == null) {\r\n      annotation.setRetryAnalyzer(MyRetryAnalyzer.class);\r\n    }\r\n\r\n  }\r\n\r\n```\r\nMyRetryAnalyzer\r\n```\r\npublic class MyRetryAnalyzer implements IRetryAnalyzer {\r\n  public static int MAX_RETRY_COUNT = 3;\r\n\r\n  // to avoid the thread safe issue, use the AtomicInteger class, instead of Integer\r\n  AtomicInteger count = new AtomicInteger(MAX_RETRY_COUNT);\r\n\r\n  public boolean isRetryAvailable() {\r\n    return (count.intValue() > 0);\r\n  }\r\n\r\n  /**\r\n   * retry a failed test\r\n   *\r\n   * @param ITestResult result - the test result of current test case\r\n   * \r\n   * @return Returns true if the test method has to be retried, false otherwise.\r\n   * \r\n   * @author Fiona Zhang\r\n   */\r\n\r\n  @Override\r\n  public boolean retry(ITestResult result) {\r\n    boolean retry = false;\r\n    if (isRetryAvailable()) {\r\n      System.out.println(\"Going to retry test case: \" + result.getMethod() + \", \"\r\n          + (MAX_RETRY_COUNT - count.intValue() + 1) + \" out of \" + MAX_RETRY_COUNT);\r\n      retry = true;\r\n      // --count\r\n      count.decrementAndGet();\r\n    }\r\n    return retry;\r\n  }\r\n}\r\n```\r\n\r\nBeforeMethod\r\n```\r\n  @BeforeMethod(alwaysRun = true)\r\n    public void beforeMethod() {\r\n\t\tAssert.assertTrue(false);\r\n}\r\n```\r\n\r\nTest\r\n```\r\n@Test\r\n public void test(){\r\n   Assert.assertTrue(false);\r\n}\r\n```\r\n> \r\n\r\n}"},"comment":{"url":"https://api.github.com/repos/cbeust/testng/issues/comments/365692892","html_url":"https://github.com/cbeust/testng/issues/1444#issuecomment-365692892","issue_url":"https://api.github.com/repos/cbeust/testng/issues/1444","id":365692892,"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},"created_at":"2018-02-14T18:02:22Z","updated_at":"2018-02-14T18:02:22Z","author_association":"COLLABORATOR","body":"@thibaut-sticky - The answer remains the same for now. TestNG doesn't retry configuration methods and AFAIK, there's no way of having TestNG do this as well."}}
{"actor":{"display_login":"krmahadevan"}}