How to generate HTML report from jacoco.exec? - eclipse

We have a Maven project which has submodules. There is one parent pom.xml
and each and every sub projects are made into a war file. Each and every submodule has unit test cases and reports generated from Jacoco.
The existing reports show unit test coverage of individual modules but we need to provide integration test-wide code coverage on Tomcat. What we did was we installed jacoco agent in Tomcat folder and configured it to to generate jacoco.exec. When I import jacoco.exec using EclEmma plugin we see the code coverage.
Is there any way to generate report from standalone jacoco.exec without source code?

Download Jacoco agent Zip file from the following URL:
https://www.jacoco.org/jacoco/ select the version that suits your needs.
Create folder with suitable name, I have mine located at "C:\jacoco". Extract the contents of the Zip file there.
Open CMD and go to C:\jacoco
Use the following command:
java -jar jacococli.jar report --classfiles path/of/the/class/files path/of/the/.exec file --html html/report/location --name nameOfTheReport
Note:
1. -jar : I have kept jacococli.jar in Jacoco.
2. --classfiles : Path of the compiled java files.
3. Path of the exec file.
4. --name : Name of HTML report Title (Heading)
Java code coverage report will be generated at your mentioned location.

Jacoco .exec files use a very optimised file format that contain compact bit sets of which checkpoints have been executed and which have not been executed, but contain no informations about line numbers.
So, to generate any report, .exec files need to be applied to class files, that contains line numbers as debug informations.
Class files are enough to produce xml reports, while also sources are needed to produce html reports (for the sake of generating html pages with coloured lines).
Most Jacoco tools to generate reports allow you to specify where to find classes and sources to properly generate reports, so if you can download those exec file to a develop machine where there are also classes and sources, you will be able to generate reports.

Related

Generating XML Resources into Classpath using Annotation Processors

I am currently working on a Gradle 3.3 project in Intellij 15.0.6.
I am using the Gradle APT plugin to add annotation processors to my classpath.
It works fine when generating Java class files, however I need to be able to generate XML sources within the resources directory equivalent in the build directory's generated directory.
Here is my build directory structure currently:
Project Build Directory Image
As you can see, it does not include a resources directory, which I suspect is what may be causing this problem.
The current exception I receive from running my annotation processor via ./gradlew assemble is: java.lang.IllegalArgumentException: Resource creation not supported in location CLASS_PATH
The code I am using within my annotation processor to generate the xml file:
FileObject source = processingEnv.getFiler()
.createResource(StandardLocation.CLASS_PATH, "", "ap-test-2.html");
Note: I used an HTML extension just as a test, XML should produce the same results.
javax.tools.StandardLocation has other output locations as well:
The SOURCE_OUTPUT location worked to place the XML within the same package as the generated Java classes, within src/apt/main. This is not my desired behaviour however. I need them to reside within the classpath.
I have not found this exception discussed anywhere else after extensive research.
Any help is appreciated. Thank you for reading this question.
StandardLocation.CLASS_PATH is only for input, not output. The only output locations are SOURCE_OUPUT (the build/generated/source/apt/… folder), CLASS_OUTPUT (the standard Gradle build/classes/…), and NATIVE_HEADER_OUPUT. See https://docs.oracle.com/javase/8/docs/api/javax/tools/StandardLocation.html
JavaC has no notion of classes vs. resources outputs, but if you run your annotation processor during your compilation then CLASS_OUTPUT should work (Gradle should then copy everything into the final directory/JAR). See https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html

Best method to export the Eclipse project as exe file

I have a selenium project in eclipse that i want to distribute to manual testers with no Eclipse or Java knowledge. Hence i am looking to distribute it to them as executable files so that they dont need to use eclipse to run them. Can any one suggest the best way to do this without having to install any 3rd party extensions?
P.S : My organisation doesnt allow me to install 3rd party extensions on Eclipse. It will require a lot of approvals. Hence i am wondering if there is any method available inside Eclipse itself?
I've done it some years ago, in my eclipse version:
file -> export -> java -> Runnable jar file
If you want an exe file you can use: Launch4J
Export your project as jar file and create a .bat file which will include all the necessary libraries in your classpath with your project and then make a call to the underlying script (in case if you are using testng then testng has option to make command line calls)
else use Maven
EDIT:
Something on below lines:
1. Create run.bat file
2. Content of the bat file:
JAVA_HOME={Path to your JDK}
CLASSPATH=%PATH%;{All the dependent jar files of your project as well as you project}
{Call to your Junit Script from command line} Something like this Run JUnit from command line
3. Run your batch file (run.bat)
I may not have provided the exact code but thats where you should be heading if you wish to run your JUnit tests from command line.
NOTE / FYI : Maven does not require any installation or approval..You just download the zip and unzip it and set environment variable and thats it.

How to save the test result of Junit with Eclipse?

i'm trying to get the result of jUnit test with Eclipse in a separate file as txt file.
What should i add in the java unit code?
I was trying with build.xml but i have the following error :
build.xml:100: java.lang.NoClassDefFoundError: org/apache/xml/serializer/ExtendedContentHandler
I tried to resolve this by adding Junit.jar but still i have the same error.
So that's i want to try to get the result in a file.
Thank you
In the top right corner of the Junit test runner, you can see a dropdown. Click that and you will find an option to export. Export the test result to the desired location. You will get the XML format of the test report in the provided location.
Generate Ant build file for your project and use Ant to generate junit reports. Refer this.
Also check this post How can I generate an HTML report for Junit results?.

NUnit step in TeamCity tries to run tests against business logic .dlls because they're in the same folder as my test .dlls

I'm setting up a CI server for my company and integrating Unit Testing. I've chosen to use TeamCity and NUnit, as they've worked well for other organizations I've worked for in the past.
I have TeamCity up and running and I've created just a test Unit Test project for now so I can verify that TC is handling my NUnit configuration properly.
My solution file contains 6 C# projects, one VB.NET project and one unmanaged c++ project. For each of those (where required) there is one separate C# project that houses the test cases for the associated project, and contains a reference to that project.
When the NUnit step runs and finds .dlls where I've told it to look, it complains that the .dll files are not the right architecture, not the right .NET version, not the right alignment of the stars etc... This is because it's trying to run NUnit against business logic .dll files, as they're built and output from the test project along with the test .dll. The test .dll file is the correct architecture, .NET version etc... as is required by NUnit.
My question is this:
How can I tell TeamCity to either
Not care if the .dll file is the correct architecture, just skip it if it isn't
Only look for the proper .dlls
I've tried to keep just a folder called Test Dlls at my root, but I can't figure out how to get every project to only put the test .dll file there.
Lastly, I will be having my coworkers generating their own unit tests for their solution files, which are not of the same layout and configuration as I described above. I really don't want to have to tell my coworkers to name their files a certain way, or set their projects to build in a particular fashion etc... if at all avoidable.

How to configure output folder for ejb stubs in RSA "prepare for deployment"

I would like to configure the output folder for the generated EJB stubs for WAS 7.0 when doing a "prepare for deployment" in RSA 8.0.
Currently the sources of the generated stubs are generated to the normal source folder of the eclipse project. Because of that generated and manually edited code is mixed. That's why I can't easily create SVN ignores for these generated files. So I would like that these files are generated to another source folder ejbmodule-gen instead of the ejbmodule source folder that contains the manually edited sources.
In the preferences I'm able to set the output folder of an EJB Project under Java EE -> Project. However this does not have an effect.
I could also use some more elaborate patterns for SVN ignores. But I don't want to mess around with them as they are already repeated much too often in build files and other places in the project.
So how can I make sure that selecting Java EE -> Prepare for Deployment will put generated source files to another folder than the original source folder of the project?
I am afraid that for EJB 2.1 the following limitation holds on Rational version 8.0:
Multiple output folders are not supported for EJB projects
However if there is enough flexibility in the project I would recommend to manually use the createEJBStubs Websphere command to generate the EJB stubs or (better) to use an ANT (or whatever) build script to build the binaries per your preference.