Hello,
I use Arquillian (which is an awesome project ) to test differents web applications using mostly the tomcat managed container.
I get problems beceause tests of a class are not independents.
Following principles of good tests, I'd like that my deployed web application never keep traces of previous tests. (http://xunitpatterns.com/Principles%20of%20Test%20Automation.html#Independent%20Test)
For exemple :
@Test public void testInsertAndGet() { beanService.insert(new Bean("name1")); Assertions.assertThat(beanService.getByName("name1")).isEqualsTo(new Bean("name1")); } @Test public void testInsertAndListAll() { beanService.insert(new Bean("first")); beanService.insert(new Bean("second")); Assertions.assertThat(beanService.getAll()).containsOnly( // Will fails if testInsertAndGet has been run before new Bean("first"), new Bean("second")); }
I already found stuff about cleaning up the database but I'd like to restore the whole application as there could be caches or other non stateless components.
I'm investigating on two points :
- Use a custom deployer which undeploy/deploy the archive between every tests
- Use tomcat manager web services to "reload" the application at the @Before step
Does anybody have a better idea ?
I'm open to every suggestions or advices which can help!
Thanks
For information I implemented an Arquillian extension to deploy and undeploy the webapp between each tests, see https://community.jboss.org/thread/231032?tstart=0
I still interested about a quickly way to do that so I let the discussion opened !