Search code examples
javamavenspring-mvctomcat7spring-roo

Maven tomcat7 deploy integration tests failure


I'm using Spring Tool Suite 3.5.1 to develop a Spring Roo 1.2.5 project. I have generated entities (without Active Record) with EclipseLink (JPA), services (implementations and intefaces) and a simple controller mainly with these commands:

  1. database reverse engineer --schema ssigdl --package ~.domain --repository --testAutomatically

  2. service all --interfacePackage ~.service --classPackage ~.service.impl

  3. web mvc setup

  4. controller class --class ~.web.CustomPageController --preferredMapping /custompage

Then I try to use maven to deploy with this goal:

  • tomcat7:deploy

When the process arrives to the part of tests, it happens these errors

Tests in error: 
  testFindEntries(com.ssigdl.sirc.domain.SsiArticuloIntegrationTest): 
(..)
  testFindAll(com.ssigdl.sirc.domain.SsiArticuloIntegrationTest): 
(..)
  testCount(com.ssigdl.sirc.domain.SsiArticuloIntegrationTest): 
(..)
  testFind(com.ssigdl.sirc.domain.SsiArticuloIntegrationTest): 
(..)
  testSave(com.ssigdl.sirc.domain.SsiArticuloIntegrationTest): 
(..)
  testDelete(com.ssigdl.sirc.domain.SsiArticuloIntegrationTest): 

And a block of errors appear one per entity created. Finally it appears the error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project sirc: There are test failures.

If I set the checkbox Skip tests in the Run Configurations Window, the compilation process goes successfully. My problem is:

  1. Why the integration tests are failing?
  2. Did I have a mistake in the spring roo commands?
  3. Does this error affect in some way to my application?

Update

This is an image of the error thrown by Spring Tool Suite

enter image description here

I can't click on the dots

Solution

I followed @mvivo instructions and I found that I had this error:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'ssigdl.sequence' doesn't exist

In this link I found the answer. Basically the entity has this annotation

@GeneratedValue(strategy = GenerationType.AUTO)

Which combined with MySQL is causing errors, so I used the following annotation instead:

@GeneratedValue(strategy = GenerationType.IDENTITY)

Thanks for your help!


Solution

  • To get information about test errors open "Navigation" view (menu Windows > Show views > Navigator) and look into target/surefire-reports. There you can found all outputs of test run.

    Why the integration tests are failing?

    Look into com.ssigdl.sirc.domain.*Test* files. There you'll found all output and stack trace of test execution

    Did I have a mistake in the spring roo commands?

    I don't think so. Is possible that you must customize test to adjust to make it run. By example, customize the DOD (Data on demand) service to get coherent data to run test.

    Does this error affect in some way to my application?

    If problem (as I suppose to) is that test do something wrong with data, you application can run perfectly if you handle data in the correct way on services.

    In my opinion, I advise you to fix the integration test generated by Roo to make it runs.

    Think that Roo just generate a template for test (and only for CRUD adn find operation) your entity but there is no way to let it know the application logic or especial rules on database tables. This kind of things always are your responsibility (sometimes looks like magic but there is none ;-) ) .