jeudi 25 janvier 2018

Integration tests of Tomcat application

I am trying to implement integration tests for my Tomcat application, but my issue is that the application is launched separately from the tests so the tests cannot access the application context and neither the database.

My idea is running the tests "within" the running application, so I can @Autowire EntityManager and check for instance the state of the database during testing or even create database entities for testing.

My only idea of doing this is to actually run the application programmatically from the tests as ClassPathXmlApplicationContext("applicationContext.xml") and the access the Context. This would work, but it would be very hard for debugging as we wouldn't be able to use Hotswapping during the testing. Also I guess the server would be stopped as soon as the tests would end. I guess that is not the best and correct solution.

Aucun commentaire:

Enregistrer un commentaire