I am using Maven Sure fire plugin to generate report for my selenium TESTNG test suites.
After the test, it generates the output in the location ..\target\local\surefire-reports.
The name of the report is emailable-report.html.
I saw that we can chnage the name of the report by passing in Pom.xml.
Below in the section in pom.xml.
But I don't see the name changed after the report is generated. Am I missing something or are there any other way to change the name of 'emailable-report.html'
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<configuration>
<outputName>desired_name</outputName>
</configuration>
</plugin>
</plugins>
</reporting>
If you only use maven-surefire-report-plugin in your POM, then yes, the outputName parameter is ignored.
If you also add maven-site-plugin to your list of build plug-ins, then you will see the effect of using the outputName parameter.
So, for example:
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>4.0.0-M2</version>
<configuration>
<locales>en</locales>
</configuration>
</plugin>
</plugins>
</build>
...
<reporting>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<outputName>emailable-report</outputName>
</configuration>
</plugin>
</plugins>
</reporting>
When you do this, you will still continue to see a file called surefire-report.html being created - but now you will also see emailable-report.html as a separate file.
Both these files are in your project's /target/site/ directory.
They contain the same reporting statistics.
There is one difference between the 2 files: The emailable-report.html file is part of the Maven project web site - and therefore it contains navigation links similar to those shown in this official example.
Which links you see depends on how you have configured your Maven project web site.
In my case, it only shows links to the SureFire report and the JavaDocs.
But you may prefer to stick with the original surefire-report.html file, because of this, and just rename it to whatever you want.
Related
Every time i'm executing my tests using maven it write the results over the previous results...
is there a way to generate the outputs on a folder with timestamp? or any other solution?
You can personalize the report name in your plugin configuration:
<project>
[...]
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.20</version>
<configuration>
<outputName>desired_name</outputName>
</configuration>
</plugin>
</plugins>
</reporting>
[...]
</project>
You can then concatenate a name with the timestamp in your pom: ${maven.build.timestamp}
Taken from here.
Additionally, you can also specify the output folder of your report. It is all there in the plugin documentation page.
I added Checkstyle to my Maven project and it's generating the report, but with broken image/style links. target/site/images/ only contains rss.png. How can I make it generate the report properly with images?
Here is the relevant part from my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version>
</plugin>
I am running maven with jxr:jxr checkstyle:checkstyle via IntelliJ. I also tried different configuration files (checkstyle.xml) from different sources.
You have to generate the site with mvn site instead of checkstyle:checkstyle to have the styles generated. See also here: https://issues.apache.org/jira/browse/MCHECKSTYLE-127
I started to use maven-surefire-report-plugin for generating test reports.
My project is composed of parent and two children.
--helloworld--pom.xml
--app1--pom.xml
--app2--pom.xml
app1 generates sources for app2 and app2 contains sources for creating war including tests.
Parent pom.xml file looks
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.7.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
When I run
mvn verify
it builds the project and run tests in the integration phase which is correct. If I browse the app2/target/site it contains report,but a little corrupted. The problem is that css and images folders are missing and that is why the report looks incomplete.
Second problem is when I run
mvn site
it generates html project reports for every folder (helloworld,app1,app2), but they are not linked correctly. I mean when I open index.html in parent folder and want to click on link app1 it gets lost,because it points wrongly. Is there any solution how to overcome these two problems?
Well I am not insisting on maven surefire report plugin for generating reports for test. Thanks in advance!
I have a project with a pom.xml that has the following <build> declaration:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
When I run mvn install on this project, it compiles the project, runs unit tests and publishes it to my local repo. I am trying to learn a little more about Maven here, and am having a tough time finding documentation/explanations on the following:
How am I able to run mvn install, if the POM doesn't declare it under build/plugins? Does maven-compiler-plugin include maven-install-plugin, if so, how could I have figured that out?
Most importantly: the value of build/plugins/plugin/configuration/source and .../target are both set to 1.8. If my machine has Java 8 on it, and I run mvn install on this project without any errors, does that guarantee that the project builds with Java 8? I'm looking at the docs for the Compiler Plugin and don't see those source/target configs listed anywhere.
First you should learn what the build life cycle is and how it works and how the plugins are bound to the life cycle by default.
Furthermore you should understand that in Maven every project inherits from the super pom file which is part of the maven distribution (the package you have downloaded). The super pom defines the default folder layout and some versions of plugins.
The question to define the maven-compiler-plugin as you did is to be very accurate simply wrong. You should have defined it like the following:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
This would overwrite the definition which is inherited by the super pom and changes it's configuration. In your case i would suggest to change the definition into this:
<project>
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
..
</project>
The encoding should be set globally cause there are other plugins which use this definition like the maven-resources-plugin. The usage of the above property simplifies this, cause every plugin which has an option for encoding will use the default as defined in the property.
To be sure using the correct version of Java (your JDK on your machine) you have to use the maven-enforcer-plugin.
Apart from that please take a look onto the plugins page which shows the most up-to-date releases of the plugins.
As a good documentation i can recomment the Books on Maven but be aware they are written with Maven 2 in mind. So if something is not clear ask on users mailing list of here on SO.
I want to use hudson to build a maven-java project. Some of my integration tests use servers which are not reachable from the hudson-server. So i want to exclude them using a special profile.
<profile>
<id>hudson</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<excludedGroups>ticketserver,print</excludedGroups>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profile
Unfortunatly i am already excluding a group in my general pom.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.10</version>
<configuration>
<excludedGroups>manual</excludedGroups>
</configuration>
Using mvn help:effective-pom i found out, that this setting overrides the one from my profile. Is there are way exclude all three test-classes when running in the hudson profile?
I though about putting the failsage-configuration in to every profile i have and removing it from the general pom but that does seem right, as i would need to repeat it for every profile i have.
Any help is greatly appreciated
Solved this by defining a property "testGroupsToSkip", which is set in the main-pom. it is then used as the value for excludedGroups. In my Profile i overwrite the property with the new value.