eviltester / blogcomments

1 stars 0 forks source link

post/junit/generating-junit-html-reports/ #34

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

Generating JUnit HTML Reports - EvilTester.com

To generate JUnit HTML reports from maven builds we need to add the surefire plugin to generate the xml files and then the site and reporting plugins to create the html report.

https://www.eviltester.com/post/junit/generating-junit-html-reports/

PramodKumarYadav commented 4 years ago

Hey Alan, Thanks for this article. I tried to run the project but I got bunch of compilation errors and the build failed. Below is the trace. Can you see if it still works on your machine? I would really love to have this plugin in my project. Cheers, Pramod

PS D:> cd .\junitexamples\ PS D:\junitexamples> code . PS D:\junitexamples> mvn clean test site [INFO] Scanning for projects... [INFO] [INFO] -----------------< uk.co.compendiumdev:junitexamples >------------------ [INFO] Building junitexamples 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ junitexamples --- [INFO] Deleting D:\junitexamples\target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ junitexamples --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\junitexamples\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ junitexamples --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! [INFO] Compiling 2 source files to D:\junitexamples\target\classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ junitexamples --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\junitexamples\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ junitexamples --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! [INFO] Compiling 26 source files to D:\junitexamples\target\test-classes [INFO] ------------------------------------------------------------- [WARNING] COMPILATION WARNING : [INFO] ------------------------------------------------------------- [WARNING] /D:/junitexamples/src/test/java/assertions/common/Junit4AssertTest.java: Some input files use or override a deprecated API. [WARNING] /D:/junitexamples/src/test/java/assertions/common/Junit4AssertTest.java: Recompile with -Xlint:deprecation for details. [WARNING] /D:/junitexamples/src/test/java/assertions/common/Junit4AssertTest.java: Some input files use unchecked or unsafe operations. [WARNING] /D:/junitexamples/src/test/java/assertions/common/Junit4AssertTest.java: Recompile with -Xlint:unchecked for details. [INFO] 4 warnings [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /D:/junitexamples/src/test/java/assertions/forexceptions/AssertJExceptionsTest.java:[3,28] package org.assertj.core.api does not exist [ERROR] /D:/junitexamples/src/test/java/assertions/softassertions/AssertJSoftAssertionsTest.java:[3,28] package org.assertj.core.api does not exist [ERROR] /D:/junitexamples/src/test/java/assertions/softassertions/AssertJSoftAssertionsTest.java:[4,30] package org.assertj.core.error does not exist [ERROR] /D:/junitexamples/src/test/java/assertions/staticimportvsaccess/AssertJStaticTest.java:[3,28] package org.assertj.core.api does not exist [ERROR] /D:/junitexamples/src/test/java/assertions/staticimportvsaccess/AssertJStaticTest.java:[6,35] package org.assertj.core.api does not exist [ERROR] /D:/junitexamples/src/test/java/assertions/staticimportvsaccess/AssertJStaticTest.java:[6,1] static import only from classes and interfaces [ERROR] /D:/junitexamples/src/test/java/assertions/common/AssertJAssertionsTest.java:[3,28] package org.assertj.core.api does not exist [ERROR] /D:/junitexamples/src/test/java/assertions/common/AssertJAssertionsTest.java:[10,35] package org.assertj.core.api does not exist [ERROR] /D:/junitexamples/src/test/java/assertions/common/AssertJAssertionsTest.java:[10,1] static import only from classes and interfaces [ERROR] /D:/junitexamples/src/test/java/assertions/forexceptions/AssertJExceptionsTest.java:[13,9] cannot find symbol

eviltester commented 4 years ago

Hi, Yes, I just tried it on my computer and it worked fine. Also when the code is pushed through to Github, a build is run on TravisCi and on Github via actions.

You don't need to run this full project to generate the html reports, if you have an existing project then try adding the html report configuration into that project and see if it works. And if all your errors are with AssertJ then try deleting those tests from the build and see if that helps.

PramodKumarYadav commented 4 years ago

Figured the issue. For our project we have to use proxies and they were not set for usage in maven. Due to this not all dependencies were pulled. Once the settings.xml file was added in root of .m2 repository, dependencies could be pulled and I now see html reports. Cheers!

rashidali242 commented 3 years ago

I am getting error , see error below. i also tried different versions but no luck so far.

Error : Plugin 'org.apache.maven.plugins:maven-surefire-report-plugin:3.0.0' not found Plugin 'org.apache.maven.plugins:maven-surefire-report-plugin:3.0.0' not found

Any idea ?