Writing windows services smoke test form
I work often with windows services, and one of the most painfully experience is that you do not have an UI and quite often they have to do some scheduled task at certain time, so whenever you have a deploy you can find yourself in this situation.
The question mark means that you are not sure if your new deploy is really ok, because maybe some of the scheduled tasks will fail for misconfiguration or something else. Usually production machine are different to developement ones, you can miss components, point to a wrong db, forget to update configuration, etc, etc. To avoid this situation you need a series of smoke checks, I usually proceed in this way.
|
|
This is the interface of the a component that is able to do a test, I can now write stuff like this
|
|
Just to verify that I’m able to resolve a specific interface or a specific component, but you can actually verify every stuff you like, then I write a simple form with a button and a ritch text box.
The next step is finding in the assembly all test classes
|
|
Thanks to fluent registration it is easy to autoregister all test classes, now the test form simply call IoC.ResolveAll<ITest> and for each test execute it in a Try catch, and here is a typical result.
Some exception occurred.
Now each time I write a component that needs verification, I write a simple test, then each time I deploy I runs this form and verify that I do not miss anything. This saves me pain, because I know that at least a set of smoke tests are passing correctly.
alk.
Tags: Software Architecture