【问题标题】:Selenium Cucumber Java Extent ReportsSelenium Cucumber Java 范围报告
【发布时间】:2018-08-25 07:35:41
【问题描述】:

我目前正在使用带有 Selenium Java 的 Cucumber 框架。我希望将我的 Normal Cucumber 报告升级为范围报告。 尝试使用范围报告 3.0.2。我能够生成范围报告,但我无法将失败的测试用例的屏幕截图嵌入到范围报告中。

任何人都可以帮助知道是否可以将失败案例的屏幕截图嵌入到 Cucumber Selenium Java 框架中。如果是,请帮助我转发与此或代码相关的任何链接。

我也想了解是否有任何其他自定义报告比范围报告更易于配置。

还请帮助我了解哪种并行执行更快。 1.Cucumber JVM并行插件 2.Maven Sure fire插件 3.测试NG并行类

如果有人能与我分享如何配置并行执行,那将是非常有帮助的。

提前感谢您的帮助。 祝你有美好的一天

【问题讨论】:

  • 添加代码。考虑拆分问题。

标签: java selenium cucumber


【解决方案1】:

我使用以下 NPM 模块,我必须在每次测试后手动运行,因为我也在 java 中运行...除非有可以以编程方式运行节点模块的 java 代码,我不知道 - cucumber-html-reporter

【讨论】:

    【解决方案2】:

    如果你可以在你的 runner 类中添加插件

    plugin = { "com.cucumber.listener.ExtentCucumberFormatter:Report/Report.html"},
    

    在截屏时尝试这个错误。它可以在 Cucumber 范围报告中添加失败测试用例的屏幕截图。

    public void forAfterScen(Scenario scenario) throws IOException
        {
            if (scenario.isFailed()) {
                String screenshotName = scenario.getName().replaceAll(" ", "_");
                try {
                    TakesScreenshot ts = (TakesScreenshot) driver;
                    File sourcePath = ts.getScreenshotAs(OutputType.FILE);
    
                    File destinationPath = new File(System.getProperty("user.dir") + "\\Report\\" + screenshotName+".png");
    
                    Files.copy(sourcePath, destinationPath);   
    
                    Reporter.addScreenCaptureFromPath(destinationPath.toString());
                    Reporter.addScenarioLog(screenshotName);
                } catch (IOException e) {
                } 
            }
        }
    

    【讨论】:

      【解决方案3】:

      使用与此类似的东西,以便在发生故障时让范围报告截取屏幕截图。祝你好运。

      public void onTestFailure(ITestResult testResult) {
              System.out.println("Method " + getTestMethodName(testResult) + " failed");
              watch.reset();
              try {
                  String path = TakeScreenshot.takeScreenshot(eDriver, testResult.getMethod().getMethodName());
                  test.addScreenCaptureFromPath(path).fail("<b>"
                          + testResult.getMethod().getMethodName().replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2").toUpperCase()
                          + "</b>" + " failed <br>"+testResult.getThrowable());
      
              } catch (IOException e) {
                  e.printStackTrace();
              }
      
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多