You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Rodriguez, John" <jo...@mlb.com> on 2012/08/09 15:44:56 UTC
RE: failsafe report displays no results
Still stumped on this. Any failsafe gurus out there? :)
-----Original Message-----
Sent: Monday, July 30, 2012 1:27 PM
Any words of wisdom from the community? :)
-----Original Message-----
Sent: Thursday, July 26, 2012 9:00 PM
I just started using "maven-failsafe-plugin" and "maven-surefire-report-plugin" so my apologies in advance...
For starters, I've configured maven-failsafe-plugin and maven-surefire-report-plugin as such (respectively):
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.12</version>
<reportSets>
<reportSet>
<id>integration-tests</id>
<reports>
<report>failsafe-report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
...
I have two test cases defined in /src/test/java/.../GameResourceIT.java like so:
public class GameResourceIT extends TestCase {
public static final String LOCAL_SERVER_URL_ROOT = "http://localhost:8080/gameservice";
public static final String GAMES_RESOURCE_URI = "/games";
public void testGetGamesForDate_20120603_status200Expected()
throws Exception {
String date = "06-03-2012";
Client client = Client.create();
WebResource webResource =
client.resource(LOCAL_SERVER_URL_ROOT + GAMES_RESOURCE_URI + "/" + date);
ClientResponse response =
webResource.accept("application/json").get(ClientResponse.class);
assertEquals("Failed : status = " + response.getStatus() + ", body = " + response.getEntity(String.class),
response.getStatus(), Status.OK.getStatusCode());
}
public void testGetGamesForDate_20120608_status404Expected()
throws Exception {
String date = "06-08-2012";
Client client = Client.create();
WebResource webResource =
client.resource(LOCAL_SERVER_URL_ROOT + GAMES_RESOURCE_URI + "/" + date);
ClientResponse response =
webResource.accept("application/json").get(ClientResponse.class);
assertEquals("Failed : status = " + response.getStatus() + ", body = " + response.getEntity(String.class),
response.getStatus(), Status.NOT_FOUND.getStatusCode());
}
}
...
When I run "mvn verify", I get the following:
[INFO] --- maven-failsafe-plugin:2.12:integration-test (default) @ gameservice --- [INFO] Failsafe report directory: ...\gameservice\target\failsafe-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running ....GameResourceIT
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.938 sec <<< FAILURE!
Results :
Failed tests:
testGetGamesForDate_20120608_status404Expected(...GameResourceIT):
Failed : status = 200, body = null expected:<200> but was:<404> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0
[INFO] --- maven-failsafe-plugin:2.12:verify (default) @ gameservice --- [INFO] Failsafe report directory:...\gameservice\target\failsafe-reports
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.753s
[INFO] Finished at: Thu Jul 26 20:39:44 EDT 2012
2012-07-26 20:39:44.644::INFO: Shutdown hook complete [INFO] Final Memory: 21M/52M [INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-failsafe-plugin:2.12:verify (default) on project gameservice: There are test failures.
Fine. As expected, 1 of the 2 tests failed. But as NOT expected, the verify goal failed as well (I thought integration test failures would not halt execution, but simply be recorded).
Now, if I look at /target/failsafe-reports/GameResourceIT.txt and /target/failsafe-reports/TEST-GameResourceIT.xml, I see as expected that 1 of 2 tests failed.
When I look at /target/failsafe-reports/failsafe-summary.xml, I see:
<failsafe-summary result="255" />
Finally, if I run "mvn:site surefire-report:report", I get an html page in /target/site/surefire-report.html that shows all 0s for the report summary (tests, errors, failures, skipped, etc.)
Why would this be the case? I expected maven-surefire-report-plugin to transform the file(s) located in /target/failsafe-reports into an equivalent HTML report (indicating that 1 of 2 tests failed) located in /target/site.
Is my configuration off?
-JR
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
</pre><hr><a href="http://mlbfancave.com"><img src="http://mlb411.mlb.com/fancave.gif" border="0" vspace="4"></a><br><i><font arial color="#000066">Check out the Cave. Visit <A href="http://mlbfancave.com">MLBFanCave.com</a></font></i><pre>
</pre><hr><a href="http://mlbfancave.com"><img src="http://mlb411.mlb.com/fancave.gif" border="0" vspace="4"></a><br><i><font arial color="#000066">Check out the Cave. Visit <A href="http://mlbfancave.com">MLBFanCave.com</a></font></i><pre>
RE: failsafe report displays no results
Posted by "Rodriguez, John" <jo...@mlb.com>.
Martin,
Thanks for your reply on this.
Since my original post, I’ve actually corrected the line you point out to, as follows:
assertEquals("Failed : status=" + response.getStatus() + ", body=" + response.getEntity(String.class), response.getClientResponseStatus(), ClientResponse.Status.OK);
However, my question is about failsafe and its behavior, not about the JUnit test itself. Namely, why is my report showing all 0s?
> As expected, 1 of the 2 tests failed. But as NOT expected, the verify goal failed as well (I thought integration test failures would not halt execution, but simply be recorded).
>
> Now, if I look at /target/failsafe-reports/GameResourceIT.txt and /target/failsafe-reports/TEST-GameResourceIT.xml, I see as expected that 1 of 2 tests failed.
> When I look at /target/failsafe-reports/failsafe-summary.xml, I see:
> <failsafe-summary result="255" />
>
> Finally, if I run "mvn:site surefire-report:report", I get an html page in /target/site/surefire-report.html that shows all 0s for the report summary (tests, errors, failures, skipped, etc.)
>
> Why would this be the case? I expected maven-surefire-report-plugin to transform the file(s) located in /target/failsafe-reports into an equivalent HTML report (indicating that 1 of 2 tests failed) located in /target/site.
>
> Is my configuration off?
Any thoughts?
-JR
From: Martin Gainty [mailto:mgainty@hotmail.com]
Sent: Thursday, August 09, 2012 10:12 AM
To: Rodriguez, John
Subject: RE: failsafe report displays no results
4.7 version of junit.framework.Assert
/** Asserts that two objects are equal. If they are not an AssertionFailedError is thrown with the given message.
*/
static public void assertEquals(String message, Object expected, Object actual) {
if (expected == null && actual == null)
return;
if (expected != null && expected.equals(actual))
return;
failNotEquals(message, expected, actual);
}
your code
assertEquals("Failed : status = " + response.getStatus() + ", body = " + response.getEntity(String.class), //This should be a String
response.getStatus(), //This *should* be an object
Status.NOT_FOUND.getStatusCode()); //This *should* be an object
Jersey implementation of getStatus() returns an int NOT an object
http://jersey.java.net/nonav/apidocs/1.4/jersey/com/sun/jersey/api/client/ClientResponse.html
http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/Response.Status.html
where getStatus() returns an int not an Object
to make ints into objects why not wrap in a simple Integer constructors
new Integer(response.getStatus()),
new Integer(Status.NOT_FOUND.getStatusCode());
Martin Gainty
______________________________________________
"Jewelry check by Jeter..he is definitely up to something"..Curt Gowdy
> From: john.rodriguez@mlb.com<ma...@mlb.com>
> To: users@maven.apache.org<ma...@maven.apache.org>
> Date: Thu, 9 Aug 2012 09:44:56 -0400
> Subject: RE: failsafe report displays no results
>
> Still stumped on this. Any failsafe gurus out there? :)
>
> -----Original Message-----
> Sent: Monday, July 30, 2012 1:27 PM
>
> Any words of wisdom from the community? :)
>
> -----Original Message-----
> Sent: Thursday, July 26, 2012 9:00 PM
>
> I just started using "maven-failsafe-plugin" and "maven-surefire-report-plugin" so my apologies in advance...
>
> For starters, I've configured maven-failsafe-plugin and maven-surefire-report-plugin as such (respectively):
>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-failsafe-plugin</artifactId>
> <version>2.12</version>
> <executions>
> <execution>
> <goals>
> <goal>integration-test</goal>
> <goal>verify</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> ...
> <reporting>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-report-plugin</artifactId>
> <version>2.12</version>
> <reportSets>
> <reportSet>
> <id>integration-tests</id>
> <reports>
> <report>failsafe-report-only</report>
> </reports>
> </reportSet>
> </reportSets>
> </plugin>
> </plugins>
> </reporting>
> ...
>
> I have two test cases defined in /src/test/java/.../GameResourceIT.java like so:
>
> public class GameResourceIT extends TestCase {
> public static final String LOCAL_SERVER_URL_ROOT = "http://localhost:8080/gameservice";
> public static final String GAMES_RESOURCE_URI = "/games";
>
> public void testGetGamesForDate_20120603_status200Expected()
> throws Exception {
> String date = "06-03-2012";
> Client client = Client.create();
> WebResource webResource =
> client.resource(LOCAL_SERVER_URL_ROOT + GAMES_RESOURCE_URI + "/" + date);
> ClientResponse response =
> webResource.accept("application/json").get(ClientResponse.class);
> assertEquals("Failed : status = " + response.getStatus() + ", body = " + response.getEntity(String.class),
> response.getStatus(), Status.OK.getStatusCode());
> }
>
> public void testGetGamesForDate_20120608_status404Expected()
> throws Exception {
> String date = "06-08-2012";
> Client client = Client.create();
> WebResource webResource =
> client.resource(LOCAL_SERVER_URL_ROOT + GAMES_RESOURCE_URI + "/" + date);
> ClientResponse response =
> webResource.accept("application/json").get(ClientResponse.class);
> assertEquals("Failed : status = " + response.getStatus() + ", body = " + response.getEntity(String.class),
> response.getStatus(), Status.NOT_FOUND.getStatusCode());
> }
> }
>
> ...
>
> When I run "mvn verify", I get the following:
>
> [INFO] --- maven-failsafe-plugin:2.12:integration-test (default) @ gameservice --- [INFO] Failsafe report directory: ...\gameservice\target\failsafe-reports
> -------------------------------------------------------
> T E S T S
> -------------------------------------------------------
> Running ....GameResourceIT
> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.938 sec <<< FAILURE!
>
> Results :
> Failed tests:
> testGetGamesForDate_20120608_status404Expected(...GameResourceIT):
> Failed : status = 200, body = null expected:<200> but was:<404> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0
>
> [INFO] --- maven-failsafe-plugin:2.12:verify (default) @ gameservice --- [INFO] Failsafe report directory:...\gameservice\target\failsafe-reports
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 13.753s
> [INFO] Finished at: Thu Jul 26 20:39:44 EDT 2012
> 2012-07-26 20:39:44.644::INFO: Shutdown hook complete [INFO] Final Memory: 21M/52M [INFO] ------------------------------------------------------------------------
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-failsafe-plugin:2.12:verify (default) on project gameservice: There are test failures.
>
>
> Fine. As expected, 1 of the 2 tests failed. But as NOT expected, the verify goal failed as well (I thought integration test failures would not halt execution, but simply be recorded).
>
> Now, if I look at /target/failsafe-reports/GameResourceIT.txt and /target/failsafe-reports/TEST-GameResourceIT.xml, I see as expected that 1 of 2 tests failed.
> When I look at /target/failsafe-reports/failsafe-summary.xml, I see:
> <failsafe-summary result="255" />
>
> Finally, if I run "mvn:site surefire-report:report", I get an html page in /target/site/surefire-report.html that shows all 0s for the report summary (tests, errors, failures, skipped, etc.)
>
> Why would this be the case? I expected maven-surefire-report-plugin to transform the file(s) located in /target/failsafe-reports into an equivalent HTML report (indicating that 1 of 2 tests failed) located in /target/site.
>
> Is my configuration off?
>
> -JR
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org<ma...@maven.apache.org>
> For additional commands, e-mail: users-help@maven.apache.org<ma...@maven.apache.org>
>
> </pre><hr><a href="http://mlbfancave.com"><img src="http://mlb411.mlb.com/fancave.gif" border="0" vspace="4"></a><br><i><font arial color="#000066">Check out the Cave. Visit <A href="http://mlbfancave.com">MLBFanCave.com</a></font></i><pre>
> </pre><hr><a href="http://mlbfancave.com"><img src="http://mlb411.mlb.com/fancave.gif" border="0" vspace="4"></a><br><i><font arial color="#000066">Check out the Cave. Visit <A href="http://mlbfancave.com">MLBFanCave.com</a></font></i><pre>
>
________________________________
B�KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKCB��[��X��ܚX�KK[XZ[
�\�\��][��X��ܚX�PX]�[��\X�K�ܙ�B��܈Y][ۘ[��[X[��K[XZ[
�\�\��Z[X]�[��\X�K�ܙ�B
</pre><hr><a href="http://mlbfancave.com"><img src="http://mlb411.mlb.com/fancave.gif" border="0" vspace="4"></a><br><i><font arial color="#000066">Check out the Cave. Visit <A href="http://mlbfancave.com">MLBFanCave.com</a></font></i><pre>