re running testng-failed.XML in same Jenkins job - jenkins

After executing test cases through Jenkins job is there a way to run testng generated testng-failed.XML in post build section and publish rerun reports also? I have to do it in the same job. I shouldn't trigger another job for this. Thanks in advance!!!!

Do as follows, it will execute your testng-failed.xml file after testng.xml. The file should exist by the time its turn to execute comes. It will be executed only once.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version><!--$NO-MVN-MAN-VER$ -->
<configuration>
<!-- Sets the VM argument line used for unit tests are run. -->
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng/testng.xml</suiteXmlFile>
<suiteXmlFile>target/surefire-reports/testng-failed.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
*******UPDATE
Implement a TestNg listener IReporter and configure it in your original testNg.xml file
It's method
GenerateReport()
Is invoked once all suites have run. In this method you must implement back up functionality of the generated testng-failed.xml .
Once this is done, testNg will proceed to rerun the testNg-failed.xml file as per my previous mentioned Maven configuration.

Related

cargo-maven2-plugin:start fails with "Actually there are no valid types registered for this configuration", regardless of what containerId I enter

I'm trying to run integration tests with the cargo-maven2-plugin and Tomcat 8. I want the Maven build to start the container for me, so I have configured the start and stop goals as documented here. The problem is that regardless of what I enter as containerId, the start goal always fails with a message saying that there are no registered configurations. The error messages always ends in
Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it?
I've tried various configurations, including ones that I found in various tutorials, and ones that user older Tomcat versions, but nothing helps. The error message is always the same.
Other posts here on Stack Overflow recommend to update the Cargo versions, but this doesn't apply to my problem: I already use the latest release version (1.6.5).
So, why do I keep getting this error?
For reference, here is one complete configuration that I tried out:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.6.5</version>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<artifactInstaller>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat</artifactId>
<version>8.5.23</version>
</artifactInstaller>
</container>
<configuration>
<type>standalone</type>
</configuration>
<deployables>
<!-- ... -->
</deployables>
</configuration>
</plugin>
The full error message for this configuration is:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.6.5:start (start-container) on project domain.db.itest: Execution start-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.6.5:start failed: Cannot create configuration. There's no registered configuration for the parameters (container [id = [tomcat8x], type = [installed]], configuration type [standalone]). Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it? -> [Help 1]
The solution was incredibly simple: I had the offline mode enabled. Without offline mode, Cargo downloaded the cargo-core-container-tomcat artifact, and apparently this artifact contains the definition of the tomcat8x configuration. Then, the container start was successful!
I had started the Maven build from Eclipse, so I didn't notice that the offline mode was enabled. I'm aware that this situation is quite special, but maybe someone else still benefits from my insight. It took me a while to solve, so I'm sharing problem and solution here. (After all, this is encouraged :-)
I got the key hint from a mailing list post, where thecargo-core-container-tomcat artifact was not downloaded due to a Nexus repository configuration.
This error is sometimes due to the cargo plugin version. Update your cargo plugin to the higher or latest version.
In my case, I updated from cargo 1.4.8 to cargo 1.7.0.
check this link,its may help:
click here

Jenkins:can not see test report tab

I can not see report tab here:
Public Junit test report:
I have configured Public JUnit test report, but I still can not see test report in left area.
As the OP joan.li adds in the comments, you need to make sure Your Jenkins installation knows about maven (as mentioned in "Jenkins executing maven from incorrect path"):
Add the default maven installation under (Jenkins -> configuration)
Goto the failing job and make sure you choose the default maven installation from dropdown
And You need to make sure your pom.xml does include a surefire build step
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
See also this example.
Check if those xml files are generated

Executing jmeter tests only if the previous jmeter test passes

I am running my jmeter tests using Jenkins and maven-jmeter plugin.
My pom.xml is configured as below.
<testFilesIncluded>
<jMeterTestFile>001-Test1.jmx</jMeterTestFile>
<jMeterTestFile>002-Test2.jmx</jMeterTestFile>
<jMeterTestFile>003-Test3.jmx</jMeterTestFile>
<jMeterTestFile>004-Test4.jmx</jMeterTestFile>
<jMeterTestFile>005-Test5.jmx</jMeterTestFile>
</testFilesIncluded>
Also, using performance plugin in jenkins for reporting.
So if my first test (001-Test1.jmx) fails (assertions fail), i do not want to execute the next test (002-Test2.jmx).
How can i accomplish this ?
Thanks for your help in advance.
I'm not sure if that helps,
but if you used TestNG you could make sure a certain number of test methods have completed and succeeded before running more test methods by setting the dependencies in testng.xml
<test name="My suite">
<groups>
<dependencies>
<group name="c" depends-on="a b" />
<group name="z" depends-on="c" />
</dependencies>
</groups>
</test>
Hope you can make some use of it.
Using ant, you can define different Jmeter tests as separate targets and set up dependencies between them. That's exactly what you need. Remember that maven describes the structure of your project, not the logic of its execution (if-then). But ant does. So, try to switch to ant.

maven-war-plugin overlay and m2e eclipse plugin

I'm trying to leverage the useful overlay feature of the maven-war-plugin.
In other words, I have a template (packaged as WAR file, template-0.0.1.war) containing tag files, css, js and images.
When I set template-0.0.1.war as a dependency of the myApp project I get a final myApp.war containing all the files of template-0.0.1.war overwritten by those with the same path in the myApp project.
This is the behavior I want.
However, I need to introduce in the pom.xml of myApp a configuration of the maven-war-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<directory>../path/to/another/dir</directory>
</resource>
</webResources>
</configuration>
</plugin>
As soon as I introduce such a configuration of the plugin, I obtain the final myApp.war with all the files from both template-0.0.1.war and myApp project but the files of template-0.0.1.war overwrite those with the same path in the myApp project.
This behavior is exactly the opposite of what I expect.
Can someone tell me where I'm wrong?
Thanks in advance.
Edit after the solution was found:
The described issue is due to the concurrency of different actions: the WAR overlay (which works correctly) and the external webResources.
In fact, the external webResources tag points to the template project directory: totally unuseful for Maven, but indispensable to "fool" the m2e eclipse plugin and let it see the custom tags contained in the template.
The solution I have adopted is to introduce 2 different profiles in the plugin section of my pom.xml: the first one called "eclipse" in which I inserted the maven-war-plugin with the webResources and a second profile (called "standard" and activated by default) without the maven-war-plugin.
From the maven war plugin documentation:
By default, the source of the project (a.k.a the current build) is added first (e.g. before any overlay is applied). The current build is defined as a special overlay with no groupId, artifactId. If overlays need to be applied first, simply configure the current build after those overlays.
If you have files in the template that are being overwritten by files in the child WAR, you may want to consider explicitly excluding them in the overlay configuration.
Here's what the documentation says to apply the overlay first:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<overlays>
<overlay>
<groupId>com.example.projects</groupId>
<artifactId>my-webapp</artifactId>
</overlay>
<overlay>
<!-- empty groupId/artifactId represents the current build -->
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>

Generating multiple javadoc reports using maven-javadoc-plugin and Maven 3

We use a custom doclet to generate a report from custom javadoc tags, and use the Maven site plugin and javadoc plugin to generate both this report and the regular java API docs.
The section of the POM looks like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<reportSets>
<reportSet>
<id>html</id>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
<reportSet>
<id>custom_report</id>
<configuration>
...
</configuration>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
</reportSets>
</plugin>
Under Maven 2, this works fine, but in Maven 3 only one report is generated, that being the last one specified in the POM (confimed by swapping the reportSet elements).
After some experimenting I discovered that if I changed the regular report's goal from "javadoc" to "test-javadoc", then I got output from both report sets. So the problem seems to be that with Maven 3 I can't generate two reports that use the same javadoc-plugin goal.
Is this a bug, or is there some congifuration I've missed? I moved the maven-javadoc-plugin setup from reporting to the configuration of the site plugin as described at http://maven.apache.org/plugins/maven-site-plugin-3.0-beta-3/maven-3.html, to no avail. I'm using Maven 3.0.4, maven-site-plugin 3.0-beta-3 and maven-javadoc-plugin 2.8.1.
Thanks!
It's a bug in maven-reporting-exec component.
Report sets are kept in a map using the report goal as a key.

Resources