extent-framework / extentreports-testng-adapter

TestNG Adapter for Extent Framework
http://extentreports.com/docs/versions/4/java/testng.html
Apache License 2.0
50 stars 14 forks source link

NullPointerException when flush() method is called #11

Closed FrankBergemann closed 4 years ago

FrankBergemann commented 4 years ago

Hi, Sorry for intruding; but I got stuck using the extentreports-testng-adapter version 1.0.6 because of a NullPointerException shown below. The code was working when using the previous Extent-Reports framework from the documentation in:

http://extentreports.com/docs/versions/4/java/testng.html

Please find my adapter config files and pom.xml at the bottom.

Console messages in Eclipse: [RemoteTestNG] detected TestNG version 7.0.1 616 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Using chromedriver 80.0.3987.106 (since Google Chrome 80 is installed in your machine) 641 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Exporting webdriver.chrome.driver as C:\Users\BERGEF.m2\repository\webdriver\chromedriver\win32\80.0.3987.106\chromedriver.exe Starting ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882}) on port 8104 Only local connections are allowed. Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code. Apr. 16, 2020 2:53:06 NACHM. org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C [1587041586.968][SEVERE]: Timed out receiving message from renderer: 0.100 [1587041587.069][SEVERE]: Timed out receiving message from renderer: 0.100 [1587041587.171][SEVERE]: Timed out receiving message from renderer: 0.100 java.lang.NullPointerException at com.aventstack.extentreports.io.ResourceUtil.moveResource(ResourceUtil.java:31) at com.aventstack.extentreports.offline.OfflineResxDelegate.saveOfflineResources(OfflineResxDelegate.java:18) at com.aventstack.extentreports.reporter.configuration.ExtentHtmlReporterConfiguration.enableOfflineMode(ExtentHtmlReporterConfiguration.java:36) at com.aventstack.extentreports.reporter.ExtentHtmlReporter.flush(ExtentHtmlReporter.java:50) at com.aventstack.extentreports.ReportObservable.lambda$23(ReportObservable.java:526) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at com.aventstack.extentreports.ReportObservable.notifyReporters(ReportObservable.java:526) at com.aventstack.extentreports.ReportObservable.flush(ReportObservable.java:424) at com.aventstack.extentreports.ExtentReports.flush(ExtentReports.java:290) at com.aventstack.extentreports.testng.listener.ExtentITestListenerClassAdapter.onFinish(ExtentITestListenerClassAdapter.java:20) at org.testng.TestRunner.fireEvent(TestRunner.java:895) at org.testng.TestRunner.afterRun(TestRunner.java:859) at org.testng.TestRunner.run(TestRunner.java:590) at org.testng.SuiteRunner.runTest(SuiteRunner.java:384) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337) at org.testng.SuiteRunner.run(SuiteRunner.java:286) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187) at org.testng.TestNG.runSuitesLocally(TestNG.java:1109) at org.testng.TestNG.runSuites(TestNG.java:1039) at org.testng.TestNG.run(TestNG.java:1007) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

extent.properties: extent.reporter.avent.start=false extent.reporter.bdd.start=false extent.reporter.cards.start=false extent.reporter.email.start=false extent.reporter.html.start=true extent.reporter.klov.start=false extent.reporter.logger.start=false extent.reporter.tabular.start=false

extent.reporter.avent.config= extent.reporter.bdd.config= extent.reporter.cards.config= extent.reporter.email.config= extent.reporter.html.config=src/test/resources/html-config.xml extent.reporter.klov.config= extent.reporter.logger.config= extent.reporter.tabular.config=

extent.reporter.avent.out=target/AventReport/ extent.reporter.bdd.out=target/BddReport/ extent.reporter.cards.out=target/CardsReport/ extent.reporter.email.out=target/EmailReport/ExtentEmail.html extent.reporter.html.out=target/HtmlReport/ExtentHtml.html extent.reporter.logger.out=target/LoggerReport/ extent.reporter.tabular.out=target/TabularReport/

html-config.xml: standard

<!-- document encoding -->
<!-- defaults to UTF-8 -->
<encoding>UTF-8</encoding>

<!-- enable or disable timeline on dashboard -->
<enableTimeline>true</enableTimeline>

<!-- protocol for script and stylesheets -->
<!-- defaults to https -->
<protocol>https</protocol>

<!-- title of the document -->
<documentTitle>SDLC Toolchain Test Report</documentTitle>

<!-- report name - displayed at top-nav -->
<reportName>Selenium/TestNG Test Automation - Quarkus todo app</reportName>

<!-- create a report with all artifacts stored locally -->
<enableOfflineMode>true</enableOfflineMode>

<!-- custom javascript -->
<scripts>
    <![CDATA[
        $(document).ready(function() {

        });
    ]]>
</scripts>

<!-- custom styles -->
<styles>
    <![CDATA[

    ]]>
</styles>

pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0 Altemista-Cloud MyFirstTestautomation 0.0.1-SNAPSHOT jar MyFirstTestautomation http://maven.apache.org
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <xray.resultsFormat>TESTNG</xray.resultsFormat>
    <xray.surefire.location>${basedir}/test-output/testng-results.xml</xray.surefire.location>
    <xray.projectKey>SDLC</xray.projectKey>

</properties>

<dependencies>

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>3.6.2</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.5</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.4</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>7.1.0</version>
        <!-- <scope>test</scope> -->
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.aventstack/extentreports-testng-adapter -->
    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports-testng-adapter</artifactId>
        <version>1.0.6</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>4.1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>4.1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml-schemas</artifactId>
        <version>4.1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-excelant -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-excelant</artifactId>
        <version>4.1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.uncommons/reportng -->
    <dependency>
        <groupId>org.uncommons</groupId>
        <artifactId>reportng</artifactId>
        <version>1.1.4</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.google.inject/guice -->
    <dependency>
        <groupId>com.google.inject</groupId>
        <artifactId>guice</artifactId>
        <version>4.2.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.mail/javax.mail-api -->
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>javax.mail-api</artifactId>
        <version>1.6.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.activation/activation -->
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
    <dependency>
        <groupId>org.dom4j</groupId>
        <artifactId>dom4j</artifactId>
        <version>2.1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans -->
    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans</artifactId>
        <version>3.1.0</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.4</version>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <!-- <version>2.21.0</version> -->
            <!-- <version>2.19.1</version> -->
            <version>3.0.0-M4</version>
            <configuration>
                <testFailureIgnore>true</testFailureIgnore>
                <suiteXmlFiles>
                    <suiteXmlFile>testng.xml</suiteXmlFile>
                </suiteXmlFiles>

                <properties>
                    <property>
                        <name>reporter</name>
                        <value>org.testng.reporters.XMLReporter:generateTestResultAttributes=true,generateGroupsAttribute=true</value>
                    </property>
                    <property>
                        <name>usedefaultlisteners</name>
                        <value>false</value>
                    </property>
                </properties>
            </configuration>
        </plugin>
    </plugins>
</build>

anshooarora commented 4 years ago

@FrankBergemann The HtmlReporter is deprecated, please use SparkReporter.

FrankBergemann commented 4 years ago

Which Properties do I have to select and define in the extent.properties file to activate the SparkReporter? Are this the avent repoter settings? -- Frank

Mit freundlichen Grüßen / Kind regards

Dr. Frank Bergemann | Managing Consultant -- Test Advisory | Brooktorkai 20, 20356 Hamburg | Mobile: +49 151 1680 2557 e-Mail: frank.bergemann@nttdata.com |


From: Anshoo Arora notifications@github.com Sent: Thursday, April 16, 2020 10:23:27 PM To: extent-framework/extentreports-testng-adapter extentreports-testng-adapter@noreply.github.com Cc: FrankBergemann frank.bergemann@nttdata.com; Mention mention@noreply.github.com Subject: Re: [extent-framework/extentreports-testng-adapter] NullPointerException when flush() method is called (#11)

@FrankBergemannhttps://github.com/FrankBergemann The HtmlReporter is deprecated, please use SparkReporter.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/extent-framework/extentreports-testng-adapter/issues/11#issuecomment-614875220, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AM6M5BDTV6HT7DDE5PNTQ2DRM5SL7ANCNFSM4MJVUZAA.

Disclaimer: This email and any attachments are sent in strictest confidence for the sole use of the addressee and may contain legally privileged, confidential, and proprietary data. If you are not the intended recipient, please advise the sender by replying promptly to this email and then delete and destroy this email and any attachments without any further use, copying or forwarding.

anshooarora commented 4 years ago

Use the below extent.properties:

extent.reporter.spark.start=true
extent.reporter.spark.config=src/test/resources/html-config.xml
extent.reporter.spark.out=target/Extent/
FrankBergemann commented 4 years ago

Hi Anshoo,

Thank you for the advice. With the new settings I got rid of the exception ☺ My test suite finishes technically ok and the test outcome is written to the console as usual.

However, no Spark-report file got generated.

I tried

I see the flush() method is called internally to generate the report html file. Is there a way to enable some log output of your adapter code for debugging?

Also, I would need to call some onFinish() listener method in addition to the @AfterMethod calls to quit the webdriver at the end of the suite. How should it implement that, e.g. by extending ExtentIReporterSuiteListenerAdapter? Do I need to define the desired reporter-type listeners in testng.xml as well?

Kind regards

n Frank

From: Anshoo Arora notifications@github.com Sent: Donnerstag, 16. April 2020 22:57 To: extent-framework/extentreports-testng-adapter extentreports-testng-adapter@noreply.github.com Cc: Bergemann, Frank Frank.Bergemann@nttdata.com; Mention mention@noreply.github.com Subject: Re: [extent-framework/extentreports-testng-adapter] NullPointerException when flush() method is called (#11)

Use the below extent.properties:

extent.reporter.spark.start=true

extent.reporter.spark.config=src/test/resources/html-config.xml

extent.reporter.spark.out=target/Extent/

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/extent-framework/extentreports-testng-adapter/issues/11#issuecomment-614891078, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AM6M5BG7YL25VOUAVWMD3YLRM5WJRANCNFSM4MJVUZAA.

Disclaimer: This email and any attachments are sent in strictest confidence for the sole use of the addressee and may contain legally privileged, confidential, and proprietary data. If you are not the intended recipient, please advise the sender by replying promptly to this email and then delete and destroy this email and any attachments without any further use, copying or forwarding.

anshooarora commented 4 years ago

It should work now, please upgrade to 1.0.7. Apparently, Spark was not part of the Service which is why the report was not being created. https://github.com/extent-framework/extentreports-testng-adapter/commit/dc93d2b34a323c61d18de193c7b5ff8df021e7d3