We do # 2 for almost all of our tests at the pier. Itβs actually very simple to create an embedded server and deploy the application, or servlet, or whatever you like about it. This gives you more than just the ability to run automated tests, as well as a way to debug your application simply in the IDE without any tool overhead. Thus, from the point of view of Jetty, we are big fans of creating your test suite and starting and stopping servers as necessary as part of this test. We have test cases when we deploy several servers and check the expiration of the session between them, others where we deploy the server and toss 10k client connections against it with our asynchronous berth. Just starting a full berth assembly starts and stops hundreds of berth server instances.
Not every application can be connected in this way, some of them have external database requirements and the like, but even there you can often write unit tests against a database in memory, for example, derby, which is a great approach to sharing your tests. If you absolutely need an environment to run your tests, many people are lucky with a combination of maven, plugty-maven-plugin and things like selenium, but I usually see them as more functional testing or acceptance test scripts, the actual mod A thorough test should be done in the context of the junit ... imo test at least.
source share