title: How can I fail a test in TestNG in an AfterMethod?
body: <p>I want to check some external log files after each test, if there were ary errors during execution. Throwing an exception in an <code>AfterMethod</code> doesn't work, because it is handled differently by TestNG: it will just fail the configuration method and not the preceding test.</p>
  
  <p>My approach would be like this:</p>
  
  <pre><code>@AfterMethod(alwaysRun = true)
  protected void tearDown(ITestResult result) {
      if (thereWasAProblemDuringTestExecution()) {
          result.setStatus(ITestResult.FAILURE);
          result.setThrowable(getSomeThrowableSomebodyStoredAnywhere());
      }
  
      // doing other cleanUp-tasks
  }
  </code></pre>
  
  <p>But still, my Eclipse TestNG plugin says the test passed.</p>
  
  <p>Is it possible (and how) to fail a test (and not only a configuration method) in a configuration method?</p>