email2vimalraj / CucumberExtentReporter

A plugin to generate the cucumber jvm custom html report using ExtentsReport
http://www.vimalselvam.com/cucumber-extent-reporter/
MIT License
58 stars 74 forks source link

Unable to generate Extent Report at Dynamic Location using Cucumber, TestNG #74

Closed vsrd13 closed 6 years ago

vsrd13 commented 6 years ago

Issue: Unable to create report in dynamic location(output/Run/report.html" with Cucumber & TestNG. I could see “output” folder along with “report.html” file, but not like this output/Run/report.html.

This issues occurs only with TestNG, but with JUnit it works fine.

Document link followed: Link: https://github.com/email2vimalraj/CucumberExtentReporter

Dependencies:

<dependency>
             <groupId>com.vimalselvam</groupId>
             <artifactId>cucumber-extentsreport</artifactId>
             <version>3.0.2</version>
        </dependency>

        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>3.1.1</version>
        </dependency>
<!-- 2nd is for Cucumber pretty and Json format Reporting -->
        <dependency>
             <groupId>net.masterthought</groupId>
             <artifactId>cucumber-reporting</artifactId>
             <version>3.5.1</version>
        </dependency>

<dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.2.5</version>
        </dependency> 
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm</artifactId>
            <version>1.2.5</version>
            <type>pom</type>
        </dependency>
        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.5</version>
        </dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>1.2.5</version>
</dependency>
<!-- ************************* Adding TestNG jar files for Runner class **************-->
<!-- https://mvnrepository.com/artifact/org.testng/testng -->

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.13.1</version>
    <scope>test</scope>
</dependency>
<!-- ******************************************************************************** -->
**<Code Snip - Test Runner Class>**
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>1.2.5</version>
</dependency>
<!-- ************************* Adding TestNG jar files for Runner class **************-->
<!-- https://mvnrepository.com/artifact/org.testng/testng -->

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.13.1</version>
    <scope>test</scope>
</dependency>
package com.cucumber.runner;
import java.io.File;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import com.cucumber.listener.ExtentProperties;
import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;

@CucumberOptions(strict = true, features = { "src/test/resources" }, plugin = {
        "com.cucumber.listener.ExtentCucumberFormatter:" }, glue = { "com.cucumber.test" }, dryRun = false)
public class TestRunnerDemo extends AbstractTestNGCucumberTests {

    @BeforeClass
    public void setUp() {
        ExtentProperties extentProperties = ExtentProperties.INSTANCE;
        // extentProperties.setExtentXServerUrl("http://localhost:1337");
        // extentProperties.setProjectName("TestNGProject");
        extentProperties.setReportPath("output/myreport.html");

    }

    @AfterClass
    public static void reportSetup() {
        Reporter.loadXMLConfig(new File("src/test/resources/extent-config.xml"));
        Reporter.setSystemInfo("User Name", System.getProperty("user.name"));
        Reporter.setSystemInfo("Time Zone", System.getProperty("user.timezone"));
        Reporter.setSystemInfo("64 Bit", "Windows 10");
        Reporter.setSystemInfo("2.53.0", "Selenium");
        Reporter.setSystemInfo("3.3.9", "Maven");
        Reporter.setSystemInfo("1.8.0_66", "Java Version");
        Reporter.setTestRunnerOutput("Cucumber JUnit Test Runner");
    }
}
email2vimalraj commented 6 years ago

Remove this line extentProperties.setReportPath("output/myreport.html"); and see. This api is to set the report path. Since you are pointing it to output/myreport.html, it doesn't generate the run time directory.

Feel free to re-open in case you need further help.