Thursday, July 10, 2014

testing without test environment - jetty

So how it actually goes?
And the answer is, as always in IT world, it depends...

For Jetty it's pretty simple.

start Jetty -> deploy war -> run tests -> stop Jetty
In order to do so we need to make sure that our application is build prior to test execution.
This is one of drawbacks, but main advantage is that if those tests will fail, main build does not.
All you need to do is add one more plugin (yep, one more!!) to your build section in pom file.

Above section does all you need. All you have to do is to properly set path to your war file, and decide under what context path your app will be available.

Just in case you'd like to test it and you don't have war file you can use, take a look at my github, there's a simple web app that does nothing, it's a "hello world" example.

Why Jetty?
Because it's light, easy to use, and in most cases will be enough.
Sure, you can use Tomcat (will show next time how to do this) but do you really need it? It's quite heavy, and configuration sometimes can give you headache.
So if you don't use any fancy stuff like JMX, Jetty will do just best.

Next time GlassFish... heavy server... but worth trying.