Fault Injection Testing with TestApi

Fault injection is the process of manipulating a software system under test so that an error is deliberately generated. For example, suppose some SUT has a method Compute() which may throw an exception under certain conditions. In one form of fault injection you modify the source code of the SUT and recompile so that any time Compute() is called by some other method, say Main(), an exception is thrown. The ideas behind fault injection are to test how well the SUT deals with exceptions, and increase code coverage. Fault injection is rather difficult in many situations because you have to either modify the SUT source code and recompile, modify the SUT binaries, or use some mechanism which modifies the behavior of the SUT at runtime. TestApi is a relatively new and growing collection of C# code which can be used to perform software testing tasks on .NET applications, libraries, and services. TestApi is hosted by the CodePlex Microsoft open source project. Here’s a snippet of what fault injection might look like:
FaultRule r1 = new FaultRule("MySUT.Compute(int, int)");
r1.Condition =  BuiltInConditions.TriggerIfCalledBy("Program.Main(string[])");
r1.Fault =  BuiltInFaults. ThrowExceptionFault(new Exception("Fatal"));
FaultSession session = new FaultSession(new FaultRule[] { r1 });
There are many other ways to perform fault injection testing but the TestApi approach is worth checking out. I am working with some of the developers of TestApi to put together a research paper for presentation at the 7th International Conference on Information Technology New Generations. See http://www.vteOnline.com/ITNG2010/ for details.
This entry was posted in Software Test Automation. Bookmark the permalink.