Note that there are some explanatory texts on larger screens.

plurals
  1. POBest practices for integration tests with Maven?
    primarykey
    data
    text
    <p>I have a project which I am building with Maven which uses Hibernate (and Spring) to retrieve data from a database, etc.</p> <p>My "tests" for the DAOs in my project extend Spring's <code>AbstractTransactionalDataSourceSpringContextTests</code> so that a DataSource can be wired into my class under test to be able to actually run the query/Hibernate logic, to fetch data, etc.</p> <p>On several other projects I've used these types of test in concert with a HSQL database (either in-memory or pointed at a file) to be able to efficiently test the actual database querying logic without relying on an external database. This works great, since it avoids any external dependencies and the "state" of the database prior to running the tests (each of which are wrapped in a transaction which is rolled back) is well defined.</p> <p>I'm curious though about the best way to organize these tests, which are really a loose flavor of integration tests, with Maven. It feels a bit dirty to keep these tests in <code>src/test/java</code>, but from what I've read there doesn't seem to be a consistent strategy or practice for organizing integration tests with Maven.</p> <p>From what I've read so far, seems like I can use the <a href="http://mojo.codehaus.org/failsafe-maven-plugin/usage.html" rel="noreferrer">Failsafe plugin</a> (or a second instance of Surefire) and bind it to the <code>integration-test</code> phase, and that I can also bind custom start-up or shutdown logic (such as for starting/stopping the HSQL instance) to <code>pre-integration-test</code> or <code>post-integration-test</code>. But, is this really the best method?</p> <p>So my question basically is - what is the generally accepted best practice on organizing this with Maven? I'm having trouble finding any sort of consistent answer in the documentation.</p> <p>What I'd like is to:</p> <ul> <li>Seperate unit tests from integration tests, so only unit tests are run during the <code>test</code> phase</li> <li>The ability to bind custom startup/shutdown logic to <code>pre-integration-test</code> and <code>post-integration-test</code></li> <li>Have the reports from the integration-tests merged/presented with the unit test Surefire reports</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload