Posts

Showing posts from July, 2010

PARAMETERIZED UNIT TEST (PUT)

Parameterized unit tests (PUTs) is a new methodology where parameters can be passed to the open unit tests by which the behavior of the test can be tested under certain scenario as well as by instantiating the parameterized test methods with given argument sets. Instantiations should be chosen so that they exercise different code paths of the methods-under-test. UNIT TESTING AT A GLANCE [i] : Three sections of Unit Tests: Data Method Sequence Assertions void Add() { int item = 3; var list = new List(); list.Add(item); var Count = list.Count(); Assert.AreEqual(1, Count); } INCOMPLETE CODE COVERAGE WITH TEST DATA: list.Add(3); Bad data may result in redundant, or worse, incomplete test suites. Fixed data values become invalid when product changes Why choose a value which may not make sense? WHAT IS PARAMETERIZED UNIT TEST? Parameterized Unit Test is a Unit Test with Parameters. Separation of concerns: Data is generat

MICROSOFT PEX and TDD

PEX stands for Program Exploration which is a white box test generation tool developed at Microsoft Research that helps developers to write PUTs in .NET platform and thus generate automated test cases. For each PUT, Pex uses dynamic test-generation techniques to compute a set of input values that exercise all the statements and assertions in the analyzed program which eventually cover all reachable branches [i] . PEX generates test inputs for parameterized unit tests (PUTs). In the context of a web service, a PUT is simply a method that takes parameters, invokes a sequence of web service operations, and asserts properties of the expected behavior of the operations [ii] . HOW TO CREATE A PEX PROJECT AND START TETSING? To work with PEX, we have to download and install Microsoft PEX white box testing framework and must have Visual Studio installed as well. Then create a test project and write a method to Test. Then right click on the method and select PEX exploration to start creating Tes