title: How take screenshot and attach it to Allure report, while using Cucumber and JUnit?
body: <p>I'm using Cucumber, Selenium, Java, Maven and JUnit stack in my automation-test-project. </p>
  
  <p>The goal is to take screenshots on fails and broken tests. I have found the solution for Java/Maven/JUnit stack:</p>
  
  <pre><code>@Rule
  public TestWatcher screenshotOnFailure = new TestWatcher() {
      @Override
      protected void failed(Throwable e, Description description) {
          makeScreenshotOnFailure();
      }
  
      @Attachment("Screenshot on failure")
      public byte[] makeScreenshotOnFailure() {
          return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
      }
  };
  </code></pre>
  
  <p>But, of course it does not work in case of using Cucumber, because it does not use any @Test methods. </p>
  
  <p>So, I've decided to change @Rule to @ClassRule, to make it listen to any fails, so here it is:</p>
  
  <pre><code>@ClassRule
  public static TestWatcher screenshotOnFailure = new TestWatcher() {
      @Override
      protected void failed(Throwable e, Description description) {
          makeScreenshotOnFailure();
      }
  
      @Attachment("Screenshot on failure")
      public byte[] makeScreenshotOnFailure() {
          logger.debug("Taking screenshot");
          return ((TakesScreenshot) Application.getInstance().getWebDriver()).getScreenshotAs(OutputType.BYTES);
      }
  };
  </code></pre>
  
  <p>And this solution didn't help me. </p>
  
  <p>So, the question is: "How to attach screenshots on fail, when I use Java/Selenium/Cucumber/JUnit/Maven in my test project?" </p>