cucumber集成extentreports测试报告

首先看一张效果图

cucumber集成extentreports测试报告_第1张图片
cucumber测试报告

接下来就是使用步骤

  1. 先在pom.xml文件中加入包引用
    
    
      com.vimalselvam
      cucumber-extentsreport
      3.0.1
    
    
      com.aventstack
      extentreports
      3.0.6
    
  1. 进入你的cucumber入口主类中
@RunWith(Cucumber.class)
@ContextConfiguration("classpath:cucumber.xml")
@CucumberOptions(
        plugin = {"com.cucumber.listener.ExtentCucumberFormatter:target/extent-report/report.html"},//1
        format = {"json:target/cucumber-report.json","pretty"},//2
        features = {"classpath:features"},
        glue = {"com.xxx.steps"},
        tags = {
                "~@performance","~@skip"
        }
)
public class CucumberTest{
    @BeforeClass
    public static void setup() {
        ExtentProperties extentProperties = ExtentProperties.INSTANCE;
        extentProperties.setReportPath("target/extent-report/myreport.html");
      //  extentProperties.setExtentXServerUrl("http://localhost:1337");
        extentProperties.setProjectName("xxx");
    }

    @AfterClass
    public static void tearDown() {
        Reporter.loadXMLConfig(new File("src/test/resources/extent-config.xml"));//1
        Reporter.setSystemInfo("user", System.getProperty("user.name"));
        Reporter.setSystemInfo("os", "Windows");
        Reporter.setTestRunnerOutput("Sample test runner output message");
    }

}

  • CucumberOptions中加入插件的属性
  • @BeforeClass注解方法中,可以使用setReportPath方法指定插件的报告生成位置
  • @AfterClass注解方法中,可以使用loadXMLConfig方法指定报告配置文件的位置

extent-config.xml



    
        dark
        UTF-8
        Cucumber Extent Reports
        Cucumber Extent Reports
        
        https
        yyyy-MM-dd
        HH:mm:ss
        
            
        
        
        
            
        
    

你可能感兴趣的:(cucumber集成extentreports测试报告)