Over a million developers have joined DZone.

When Unit Testing a Server, Why Not USE the Server?


One of the most interesting aspects of build RavenDB was that it opened up my mind to the way we can use the fundamental nature of the server to open up additional information about the server operations.

One thing that I noticed recently is that if I need to debug a test for RavenDB, I often need to stop the current thread (the Test thread) and then go to the server test instance to look at what is actually going on in there.

The fun part is that this is really nice, because I can go an inspect the running test instance, see what is going on, and then modify things to see how they affect the behavior, etc. The only problem is that this is actually quite complex to set up manually (stop on debugger, freeze the appropriate thread, resume run, inspect server – modify stuff there, stop on debugger, thaw thread, continue run, etc).

What occurred to me, however, is that I can codify this behavior, and end up with this:


This method will only operate while a debugger is attached, but it is going to save me a lot of time.  Once I am done, I need to delete the marker document:


This is especially important if you are running in memory mode, since the moment the test is over, the database is completely wiped out.


Published at DZone with permission of Ayende Rahien, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}