Note that there are some explanatory texts on larger screens.

plurals
  1. POIn-container testing vs. mock objects for integration testing
    text
    copied!<p>In-container testing is often opposed to testing with mock objects. However, as mock objects simply mimic the behavior of the real objects, isn't the in-container testing the only way to really test the system in its' real environment?</p> <p>As an partial alternative to in-container testing and mock objects, Spring provides the <code>TestContext</code> framework that initializes Spring nicely without needing to start up the actual application container (web application server, in my case). However, this is somewhat limited approach as it only initializes Spring-specific features while the application server -specific features are not supported. So you cannot test everything. Also, as it is not 100% the same as the default <code>WebApplicationContext</code> that is used in real web execution, isn't this approach a bit hackyish? Is it bad?</p> <p>For in-container testing, there are at least <a href="http://jakarta.apache.org/cactus/" rel="nofollow noreferrer">Cactus</a> (outdated), <a href="http://code.google.com/p/jeeunit/" rel="nofollow noreferrer">Jeeunit</a> (a very little project) and <a href="http://jboss.org/arquillian" rel="nofollow noreferrer">JBoss Arquillian</a> (still alpha, but looks promising). I don't see any of these projects too widely used, so is there something bad with in-container testing? The main drawback often mentioned with in-container testing is slow execution speed. However, when run in a continuous integration environment and in a relatively small project, this shouldn't be a problem.</p> <p>To summarize: should we do either in-container or out-container testing and why? Would you feel bad using mock objects or an alternative initialization mechanism (as in Spring TestContext) for your integration tests?</p> <p>A subnote: I recently asked about <a href="https://stackoverflow.com/questions/3245528/is-integration-testing-an-umbrella-term-and-if-so-what-types-of-tests-does-it-in">categorization of integration test</a>, which might be relevant.</p>
 

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