0

for some testing purposes it would be great not having to restart my jetty server for every test run.

With jrebel i can apply source changes directly.

Is it possible to run my jetty server in a way that i could inject changes dynamically and then rerun the tests without having to restart the server?

Alex
  • 8,518
  • 4
  • 28
  • 40
  • So this would be a great idea to combine junit with the server and jrebel ;) in the described manner – Alex Apr 28 '11 at 14:44

1 Answers1

1

It depends on the kind of changes that you want to inject.

That said, I believe there is a deeper issue here. Restarting Jetty is the right thing to do from a test-quality standpoint. It ensures that each test starts from a clean page thereby minimizing the risk of inter-test dependencies. On the other hand, this is costly (time-wise) and make your suite runs slower.

If I were you, I would address this as follows: I will refactor the code that I want to test (presumably: servlets) such that they do not depend on the Jetty infrastructure, and can run stand-alone. For instance, If I have a servlet class SomeServlet with its doGet() method, I will refactor it such that it implement MyServelt whose goGet() takes a MyRequest, MyResponse parameters.

Once you do that, you can unit-test MyServlet without a Jetty server. This will allow you not only to test faster, but also ease your debugging sessions and make your components more decoupled. Of course, you will need to add some plumbing code: a class that adapts the servelt interface to a MyServelt object (via delegation).

Itay Maman
  • 30,277
  • 10
  • 88
  • 118
  • yes,Restarting Jetty is the right thing to do when from a test-quality standpoint. But if you do testing normally you rerun tests in a smaller part of your project, sometimes just a very little number of tests. For final testing issues you woud run in quality safe way but for fast developing the injecting would be enough. – Alex Apr 28 '11 at 15:09