I’ve just completed my first proof of concept which I’m very excited about and I just had to write a quick blog about it – plus it breaks my blogging silence.
I find fault injection an interesting concept, I’ll explore it in more detail in later posts, but the aim is to insert exceptions at various points in order to test certain behaviours and how the application copes when an error occurs. However, raising exceptions is not a easy task, you have to create the scenario and environment in order for the exception to occur. With my fault injection application, you don’t need to create the scenario, you simply say when you want the exception to occur. For example, I would be able to throw an IOException when System.IO.File.ReadAllLines() is called without actually having to create the scenario for the exception to be raised – saving me time and effort but also allowing me to test more scenarios and error handling.
Tonight, I created a very simple concept to throw exceptions on method calls. I’ve got a very simple console application which calls two methods – nothing special about this. When MethodFails() is called, my injector will step in and throw a MethodAccessException (could be any exception) which will be caught by the console application with the details of the exception being outputted.
static void Main(string args)
Console.WriteLine(“Should output 1 message then fail”);
catch (Exception e)
Console.WriteLine(“Type: ” + e.GetType());
Console.WriteLine(“Message: ” + e.Message);
private static void MethodA()
Console.WriteLine(“This should work”);
private static void MethodFails()
Console.WriteLine(“this should have failed”);
The output of the execution is the following information:
Should output 1 message then fail
This should work
Message: You attempted to call ConsoleApplication2.Program.MethodFails, this has been blocked. Goodbye
Technical details to come at a later point, it’s getting late in the UK. However, I would love to hear your comments on this idea.