<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Nikolai Tillmann's Blog</title><link>http://blogs.msdn.com/nikolait/default.aspx</link><description>Nikolai works at Microsoft Research, leading the Pex project.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Pex 0.18 Released: New Tutorials, Moles work with Visual Studio 2010</title><link>http://blogs.msdn.com/nikolait/archive/2009/10/15/pex-0-18-released-new-tutorials-moles-work-with-visual-studio-2010.aspx</link><pubDate>Thu, 15 Oct 2009 18:23:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9907791</guid><dc:creator>nikolait</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/9907791.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=9907791</wfw:commentRss><description>&lt;p&gt;We just released a maintenance update of &lt;a href="http://research.microsoft.com/pex"&gt;Pex&lt;/a&gt;. Together with this release come new tutorials, and support for Moles in Visual Studio 2010. As usual, this release also contains a number of bug fixes and small feature improvements, most of which address your suggestions from the &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/pex/threads/"&gt;Pex forum&lt;/a&gt; and bug reports sent to &lt;a href="mailto:pexbug@microsoft.com"&gt;pexbug@microsoft.com&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;New Tutorials: Stubs and Moles, and Unit Testing SharePoint with Pex&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you felt that you didn’t know how to get started with Stubs, Moles, and Pex, then you will like the following two tutorials. They are bundled in the Pex installer, and you can also get them from our website:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;u&gt;“Stubs - Lightweight Test Stubs And Moles for .NET - Getting Started Tutorial”        &lt;br /&gt;&lt;/u&gt;This document provides a short, step-by-step tutorial for the Stubs framework.       &lt;br /&gt;&lt;a title="http://research.microsoft.com/en-us/projects/stubs/stubstutorial.pdf" href="http://research.microsoft.com/en-us/projects/stubs/stubstutorial.pdf"&gt;http://research.microsoft.com/en-us/projects/stubs/stubstutorial.pdf&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;u&gt;“Unit Testing SharePoint Services with Pex”        &lt;br /&gt;&lt;/u&gt;This document provides a short, step-by-step tutorial on how to write isolated unit test for SharePoint Services using the Stubs framework and apply Pex to generate a test suite with code coverage.       &lt;br /&gt;&lt;a title="http://research.microsoft.com/en-us/projects/pex/pexsharepoint.pdf" href="http://research.microsoft.com/en-us/projects/pex/pexsharepoint.pdf"&gt;http://research.microsoft.com/en-us/projects/pex/pexsharepoint.pdf&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Moles for Visual Studio 2010&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The [HostType(Pex)] attribute, which is required to execute generated, or hand-written parameter-less test cases that Moles, now also works with unit tests in Visual Studio 2010.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Breaking Changes&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;The code generation of Moles has changed again. This might mean that you will have to recompile your solution, and adapt all existing uses of Moles.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9907791" width="1" height="1"&gt;</description></item><item><title>How do you use Pex in Visual Studio? Your Input Is Needed!</title><link>http://blogs.msdn.com/nikolait/archive/2009/09/09/how-do-you-use-pex-in-visual-studio-your-input-is-needed.aspx</link><pubDate>Thu, 10 Sep 2009 04:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9893424</guid><dc:creator>nikolait</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/9893424.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=9893424</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://blogs.msdn.com/nikolait/archive/2008/10/24/pex-now-a-devlabs-project.aspx" target=_blank mce_href="http://blogs.msdn.com/nikolait/archive/2008/10/24/pex-now-a-devlabs-project.aspx"&gt;Since it’s been almost a year that we’ve released Pex&lt;/A&gt;, we have started a little survey on &lt;A href="http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99" target=_blank mce_href="http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99"&gt;our forums&lt;/A&gt;. &lt;STRONG&gt;We are looking for feedback on how you use Pex and how you would like to use it. &lt;/STRONG&gt;If you are interested, please voice yourself&amp;nbsp; on our mini survey at&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A title=http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99 href="http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99" mce_href="http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99"&gt;&lt;STRONG&gt;http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The questions are:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;1. Are you using Pex already? A) From Visual Studio, B) the command-line, C) other, D) no&lt;BR&gt;2. Which version of Visual Studio are you using? A) Professional, B) Team System, C) other&lt;BR&gt;3. How many people are in your team?&lt;BR&gt;4. Do you write A) Parameterized Unit Tests (PUTs), or B) only use the Wizard-generated PUT stubs?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Any other comments are appreciated as well, about the license terms, or required Visual Studio versions…&lt;BR&gt;Thanks,&amp;nbsp; The &lt;A href="http://research.microsoft.com/pex" target=_blank mce_href="http://research.microsoft.com/pex"&gt;Pex&lt;/A&gt; Team&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9893424" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/nikolait/archive/tags/survey/default.aspx">survey</category><category domain="http://blogs.msdn.com/nikolait/archive/tags/Pex/default.aspx">Pex</category></item><item><title>Pex 0.13 Released: Unit Tests as Inputs, Fuzzing and Visual Studio 2010 Beta 1, F# Beta 1 support</title><link>http://blogs.msdn.com/nikolait/archive/2009/05/28/pex-0-13-released-unit-tests-as-inputs-fuzzing-and-visual-studio-2010-beta-1-f-beta-1-support.aspx</link><pubDate>Fri, 29 May 2009 03:05:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9651098</guid><dc:creator>nikolait</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/9651098.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=9651098</wfw:commentRss><description>&lt;p&gt;We just released an update of &lt;a href="http://research.microsoft.com/pex"&gt;Pex&lt;/a&gt; that brings a very cool new feature, &lt;strong&gt;Unit Tests as Inputs&lt;/strong&gt; and updates for Visual Studio 2010 Beta 1, Code &lt;a href="http://research.microsoft.com/contracts"&gt;Contracts&lt;/a&gt; and F# Beta 1. As usual, this release also contains a number of bug fixes and small feature improvements, most of which address your suggestions from the &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/pex/threads/" target="_blank"&gt;Pex forum&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Seeding the Exploration Part 1: Unit Tests as Inputs&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Before using heavy-weight constraint solving to explore hard-to-reach execution paths, Pex can now leverage already existing unit tests that call a parameterized unit tests: Pex scans their body to extract the parameter values, and then Pex uses these values to seed the exploration. (In the past, Pex would have seeded the exploration by simply using the default values for all parameters, and nothing else.)&lt;/p&gt;  &lt;p&gt;Here is an example, where Pex starts the exploration of the parameterized unit test Multiply by reusing the values mentioned in the unit test MultiplySeed, as you can see in the first row of the table of generated tests.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.13ReleasedNowwithfreshExplorationSee_1BFC/image5.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="362" alt="image" src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.13ReleasedNowwithfreshExplorationSee_1BFC/image5_thumb.png" width="716" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As a (intended) side effect, Pex also reuses the tests that Pex might have generated during earlier explorations. In effect, Pex never has to start from scratch again, but instead can reuse knowledge from earlier explorations.&lt;/p&gt;  &lt;p&gt;There is a big limitation in this first version of the new feature: Pex can only use values of primitive types, and arrays of primitive types as seeds, and the values must be passed as parameters, not via PexChoose. The unit tests must be in the same class as the parameterized unit test, marked as a unit test, and have a simple structure, i.e., they must just create the input data, and the first method call must be to a parameterized unit test.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Seeding the Exploration Part 2: [PexArgument(…)] to Fuzz Inputs and Help Pex&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Pex can not only extract values from existing unit tests, but there is in fact a general API through which seed values can be given. In particular, you can use the new PexArgumentAttribute (and a bunch of related new attributes) to provide seed values. &lt;/p&gt;  &lt;p&gt;Here is an example:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.13ReleasedNowwithfreshExplorationSee_1BFC/image10.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="344" alt="image" src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.13ReleasedNowwithfreshExplorationSee_1BFC/image10_thumb.png" width="717" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;During the subsequent exploration, Pex will often reuse parts of the seeded values, which may make constraint solving easier for Pex. Also, when Pex cannot solve all constraints to leap beyond a difficult branch, then you can use this feature to help Pex by providing the values yourself.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Object Creation with Invariants&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Code Contracts enable the specification of class invariants by writing an “invariant method” decorated with the ContractInvariantMethod attribute. For example, for a typical ArrayList implementation, this invariant method might read as follows:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ArrayList {
        &lt;span class="kwrd"&gt;private&lt;/span&gt; Object[] _items;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; _size;
        ...
        [ContractInvariantMethod] // attribute comes with Code Contracts, not Pex
        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Invariant() {
            Contract.Invariant(&lt;span class="kwrd"&gt;this&lt;/span&gt;._items != &lt;span class="kwrd"&gt;null&lt;/span&gt;);
            Contract.Invariant(&lt;span class="kwrd"&gt;this&lt;/span&gt;._size &amp;gt;= 0);
            Contract.Invariant(&lt;span class="kwrd"&gt;this&lt;/span&gt;._items.Length &amp;gt;= &lt;span class="kwrd"&gt;this&lt;/span&gt;._size);
        }&lt;/pre&gt;

&lt;p&gt;If you have such an invariant, and if you correctly configure &lt;em&gt;runtime checking &lt;/em&gt;of contracts, then Pex will create instances of this type by first creating a raw instance, setting all private fields directly, and then making sure that the invariant holds. A generated test case for the Add method of the ArrayList class might then read as follows:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[TestMethod]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Add01() {
    &lt;span class="kwrd"&gt;object&lt;/span&gt;[] os = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;[0];
    ArrayList arrayList = PexInvariant.CreateInstance&amp;lt;ArrayList&amp;gt;();   &lt;span class="rem"&gt;// creates raw instance&lt;/span&gt;
    PexInvariant.SetField&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;[]&amp;gt;(arrayList, &lt;span class="str"&gt;&amp;quot;_items&amp;quot;&lt;/span&gt;, os); &lt;span class="rem"&gt;// sets private field via reflection&lt;/span&gt;
    PexInvariant.SetField&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;(arrayList, &lt;span class="str"&gt;&amp;quot;_size&amp;quot;&lt;/span&gt;, 0);        &lt;span class="rem"&gt;// same&lt;/span&gt;
    PexInvariant.CheckInvariant(arrayList);                   &lt;span class="rem"&gt;// invokes invariant method via reflection&lt;/span&gt;
    arrayList.Add(&lt;span class="kwrd"&gt;null&lt;/span&gt;);                                      &lt;span class="rem"&gt;// call to method-under-test&lt;/span&gt;
}&lt;/pre&gt;

&lt;p&gt;A limitation of the current implementation is that the type itself must be public, and the types of all fields must be public (but not the fields themselves.)&lt;/p&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Surviving unhandled exceptions in Finalizers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finalizers are especially problematic for test runners: there is no guarantee from the runtime when they will be executed, and when they throw an exception, the process terminates. This is not an uncommon scenario when you apply Pex to (buggy) code with Finalizers: It seems as if Pex suddenly crashes.&lt;/p&gt;

&lt;p&gt;In this version, we have improved the robustness of Pex with respect to those failures. Pex effectively rewrites all finalizers of instrumented types with a catch handler that swallows all exceptions and sends it to Pex’ logging infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Visual Studio 2010 Beta 1 support&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;We’ve updated Pex for Visual Studio 2010 Beta 1, the latest Code Contracts version and F# Beta 1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Send Feedback at your fingertips&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We made it even easier for you to ask questions about Pex, or to just tell us what you think, right from Visual Studio: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.13ReleasedNowwithfreshExplorationSee_1BFC/image_2.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="85" alt="image" src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.13ReleasedNowwithfreshExplorationSee_1BFC/image_thumb.png" width="644" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bug fixes and other small features&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The &lt;a href="http://research.microsoft.com/stubs"&gt;Stubs&lt;/a&gt; framework generates stubs for types containing obsolete members. This behavior can be disabled. &lt;/li&gt;

  &lt;li&gt;The wizard can generate tests for inherited members by adding the&lt;em&gt; &lt;/em&gt;&lt;strong&gt;&lt;i&gt;/gim&lt;/i&gt;&lt;/strong&gt; flag or from the wizard settings/options. &lt;/li&gt;

  &lt;li&gt;The default test assembly name suffix string, i.e., the suffix used to generate the test assembly name, can be specified on the wizard command line, e.g. &lt;strong&gt;&lt;i&gt;/tans:.PexTests&lt;/i&gt;&lt;/strong&gt;, or in the Visual Studio options (Tools –&amp;gt; Options –&amp;gt; Pex –&amp;gt; Wizard –&amp;gt; Test Assembly Name Format String). &lt;/li&gt;

  &lt;li&gt;int ChooseIndexValue&amp;lt;T&amp;gt;(string, T[]) was added to the choice API to choose valid index values. &lt;/li&gt;

  &lt;li&gt;We added new overloads in PexAssume/PexAssert that support IEnumerable&amp;lt;T&amp;gt;, i.e. for AreElementsEqual etc… &lt;/li&gt;

  &lt;li&gt;Better understanding of _.GetType(), and conditions involving System.Type values.&lt;/li&gt;

  &lt;li&gt;The Stubs framework can assign values to ref parameters.&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9651098" width="1" height="1"&gt;</description></item><item><title>Pex 0.12 Released: Exploration Tree View, Partial Stubs…</title><link>http://blogs.msdn.com/nikolait/archive/2009/05/01/pex-0-12-released-exploration-tree-view-partial-stubs.aspx</link><pubDate>Sat, 02 May 2009 06:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9583330</guid><dc:creator>nikolait</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/9583330.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=9583330</wfw:commentRss><description>&lt;DIV class=itemContents&gt;
&lt;DIV class=itemBody&gt;Peli just announced the latest &lt;A class="" title=Pex href="http://research.microsoft.com/en-us/projects/pex" target=_blank mce_href="http://research.microsoft.com/en-us/projects/pex"&gt;Pex&lt;/A&gt;&amp;nbsp;Release,version 0.12.40430.3. Get &lt;A class="" title="Pex 0.12" href="http://blog.dotnetwiki.org/2009/05/01/Pex012404303ExplorationTreeViewPartialStubs.aspx" mce_href="http://blog.dotnetwiki.org/2009/05/01/Pex012404303ExplorationTreeViewPartialStubs.aspx"&gt;all the details&lt;/A&gt; on his blog.&lt;/DIV&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9583330" width="1" height="1"&gt;</description></item><item><title>Pex 0.11 Released: Delegates, Exception Trees, and Stubs</title><link>http://blogs.msdn.com/nikolait/archive/2009/04/21/pex-0-11-released-delegates-exception-trees-and-stubs.aspx</link><pubDate>Wed, 22 Apr 2009 02:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9560687</guid><dc:creator>nikolait</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/9560687.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=9560687</wfw:commentRss><description>&lt;P&gt;We just released &lt;A href="http://research.microsoft.com/pex" mce_href="http://research.microsoft.com/pex"&gt;Pex&lt;/A&gt; v0.11.40421.0, which you can &lt;A href="http://research.microsoft.com/en-us/projects/pex/downloads.aspx" target=_blank mce_href="http://research.microsoft.com/en-us/projects/pex/downloads.aspx"&gt;download here&lt;/A&gt;. This release brings support for &lt;STRONG&gt;Delegates as Parameters&lt;/STRONG&gt;, a new &lt;STRONG&gt;Exception Tree View&lt;/STRONG&gt;, &lt;STRONG&gt;Stubbed Events&lt;/STRONG&gt;, and &lt;STRONG&gt;Recursive Stubs.&lt;/STRONG&gt; This also release fixes a blocking issue (incorrect registration of the Stubs Visual Studio Add-in), and it brings Pex in sync with the latest Code &lt;A href="http://research.microsoft.com/en-us/projects/contracts/" target=_blank mce_href="http://research.microsoft.com/en-us/projects/contracts/"&gt;Contracts&lt;/A&gt; release.&lt;/P&gt;
&lt;P&gt;Update: This release may still require a separate download of OpenMP dlls, which part of the &lt;A class="" href="http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&amp;amp;displaylang=en"&gt;vcredist&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Delegate As Parameters&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Pex now understands Parameterized Unit Tests that take &lt;STRONG&gt;delegates as parameters&lt;/STRONG&gt;. Pex will automatically generate a delegate instance and its behavior: if the delegate returns a value, Pex will generate a new symbolic value for it, track its use, and then generate different values depending on the program behavior. Let’s consider a simple method to illustrate this new feature. I wrote the following Parameterized Test method which takes a Func&amp;lt;int&amp;gt; delegate and throws an exception if the delegate returns a particular value:&lt;/P&gt;
&lt;P&gt;&lt;A href="file:///C:/Users/jhalleux/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles74A18E2/image8.png" mce_href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles74A18E2\image8.png"&gt;&lt;IMG title=clip_image002 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=91 alt=clip_image002 src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image002_6edebc61-217e-4ce8-8aa8-6ec045880715.gif" width=333 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image002_6edebc61-217e-4ce8-8aa8-6ec045880715.gif"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;When executing Pex on Test, Pex will generate a Func&amp;lt;int&amp;gt; which ‘asks’ Pex to choose the returned int (it uses PexChoose under the hood). Therefore, for each call to that delegate, Pex has the liberty to return a diferent value. Based on how it is used, Pex will generate different values to increase coverage. In this case, Pex ‘chooses’ to return 123 on the first call, which is exactly what we need to cover the exception branch. The following code is generated by Pex; it starts by setting up the desired values, and then it calls the parameterized unit test.&lt;/P&gt;
&lt;P&gt;&lt;A href="file:///C:/Users/jhalleux/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles74A18E2/image4.png" mce_href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles74A18E2\image4.png"&gt;&lt;IMG title=clip_image004 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=179 alt=clip_image004 src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image004_c9456251-ff18-4c25-8b48-3a6a0dc1ba3b.gif" width=439 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image004_c9456251-ff18-4c25-8b48-3a6a0dc1ba3b.gif"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Pex Explorer: Exception Tree View&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;We have started to work on improving the experience when applying Pex to a large number of explorations. To this end, a new window called &lt;STRONG&gt;Pex Explorer &lt;/STRONG&gt;will show various views over the events produced by Pex. The &lt;STRONG&gt;Exception Tree View &lt;/STRONG&gt;provides the tree of exception types that Pex found. This is really helpful to quickly drill through the (really) bad exceptions first.&lt;/P&gt;
&lt;P&gt;&lt;A href="file:///C:/Users/jhalleux/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles74A18E2/image31.png" mce_href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles74A18E2\image31.png"&gt;&lt;IMG title=clip_image006 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=187 alt=clip_image006 src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image006_571bfa9e-c70f-46df-bf98-ffc241522c30.gif" width=360 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image006_571bfa9e-c70f-46df-bf98-ffc241522c30.gif"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Pex Explorer: Contract Failures Tree View&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you are using Code &lt;A href="http://research.microsoft.com/contracts" mce_href="http://research.microsoft.com/contracts"&gt;Contracts&lt;/A&gt;, Pex also provides a specialized view to sort the contract failures kind.&lt;/P&gt;
&lt;P&gt;&lt;A href="file:///C:/Users/jhalleux/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles74A18E2/image1[1].png" mce_href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles74A18E2\image1%5b1%5d.png"&gt;&lt;IMG title=clip_image008 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=170 alt=clip_image008 src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image008_c2f0e5cc-1914-4fc8-b3be-7194c8a22a91.gif" width=360 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image008_c2f0e5cc-1914-4fc8-b3be-7194c8a22a91.gif"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Events in Stubs&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://research.microsoft.com/stubs" mce_href="http://research.microsoft.com/stubs"&gt;Stubs&lt;/A&gt;&lt;/STRONG&gt; now support events: the stubs simply expose the backing delegate fields (which hold the event delegate) as a public fields. As a result, one can clear, set, and invoke the event as any other member. Let’s see this with an example:&lt;/P&gt;
&lt;P&gt;&lt;A href="file:///C:/Users/jhalleux/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles74A18E2/image[7].png" mce_href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles74A18E2\image%5b7%5d.png"&gt;&lt;IMG title=clip_image010 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=57 alt=clip_image010 src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image010_e1d38f4d-c258-4c91-8295-c33cb6ce08d0.gif" width=275 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image010_e1d38f4d-c258-4c91-8295-c33cb6ce08d0.gif"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In order to raise the SomeEvent in a test, we would simply have to invoke the backing delegate field, which happens to have the same name as the event:&lt;/P&gt;
&lt;P&gt;&lt;A href="file:///C:/Users/jhalleux/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles74A18E2/image[8].png" mce_href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles74A18E2\image%5b8%5d.png"&gt;&lt;IMG title=clip_image012 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=58 alt=clip_image012 src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image012_8256d279-6d1c-45de-a017-b263fa6431e5.gif" width=427 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image012_8256d279-6d1c-45de-a017-b263fa6431e5.gif"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It’s that simple.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Recursive Stubs&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Another common feature of mock/stub frameworks is to support nested invocation of members. Stubs now lets you recursively invoke property getters. Instead of assigning the property getter delegate, you can use new helper methods ending in ‘AsStub’ that take care of allocating the nested stub, assigning it to the property getter and returning it. Let’s see this with an example: assume we want to test the little snippet below.&lt;/P&gt;
&lt;P&gt;&lt;A href="file:///C:/Users/jhalleux/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles74A18E2/image[16].png" mce_href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles74A18E2\image%5b16%5d.png"&gt;&lt;IMG title=clip_image014 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=41 alt=clip_image014 src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image014_c52a8814-5322-4e0e-b9ce-72c025cb1e84.gif" width=260 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image014_c52a8814-5322-4e0e-b9ce-72c025cb1e84.gif"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In order to set up our stub, we would need to have IParent.Child return a stub of IChild, then set up IChild.Name to return ‘joe’. For property getters, Stubs generates a helper method that does just that:&lt;/P&gt;
&lt;P&gt;&lt;A href="file:///C:/Users/jhalleux/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles74A18E2/image[15].png" mce_href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles74A18E2\image%5b15%5d.png"&gt;&lt;IMG title=clip_image016 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=40 alt=clip_image016 src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image016_a48a274e-26b8-4a98-95da-042a03a6cd39.gif" width=458 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.11Released_A41B/clip_image016_a48a274e-26b8-4a98-95da-042a03a6cd39.gif"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The ChildGetAsStub call instantiated a SIChild instance, assigned to the Child property and returned it. It’s that simple.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Fixed Bugs&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;.Stubx fail to generate the stubs. We fixed a bug with the registration of Stubs in Visual Studio. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Breaking Changes&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Microsoft.Stubs.dll has been renamed to Microsoft.Stubs.Framework.dll. The public Stubs type has been moved under the Microsoft.Stubs.Framework namespace. &lt;/LI&gt;
&lt;LI&gt;The generated stub class names are built by prepending ‘S’ to the type name (‘IFoo’ –&amp;gt; ‘SIFoo’). In the previous version, the ‘I’ of interface name was trimmed which sometimes created name clashes. &lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9560687" width="1" height="1"&gt;</description></item><item><title>Pex 0.10 Released / ICSE Tutorial on Parameterized Unit Testing</title><link>http://blogs.msdn.com/nikolait/archive/2009/04/10/pex-0-10-released-icse-tutorial-on-parameterized-unit-testing.aspx</link><pubDate>Fri, 10 Apr 2009 22:42:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9543900</guid><dc:creator>nikolait</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/9543900.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=9543900</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://blog.dotnetwiki.org/2009/04/10/PexV010404080NUnitMbUnitXUnitNetVisualBasicNETFAndMore.aspx" target="_blank"&gt;Peli just announced&lt;/a&gt; that we have released &lt;a href="http://research.microsoft.com/en-us/projects/pex/"&gt;Pex&lt;/a&gt; &lt;a href="http://research.microsoft.com/en-us/projects/pex/downloads.aspx"&gt;version 0.10&lt;/a&gt;. (You didn’t think that after version 0.9 we would go straight to version 1.0, did you?)&lt;/p&gt;  &lt;p&gt;There are &lt;a href="http://research.microsoft.com/en-us/projects/pex/releasenotes.aspx#0_10_40408_0"&gt;many exciting improvements&lt;/a&gt;, including better support for other test frameworks, VB.NET, F#, assertion generation, Code Contracts, and Stubs. Many of the changes are thanks to your &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/pex/threads/" target="_blank"&gt;feedback on our MSDN Pex Forum&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Also, together with &lt;a href="http://www.csc.ncsu.edu/faculty/xie/" target="_blank"&gt;Tao Xie&lt;/a&gt;, we are going to give a &lt;a href="http://ase.csc.ncsu.edu/put/" target="_blank"&gt;Tutorial on Parameterized Unit Testing&lt;/a&gt; at the International Conference of Software Engineering (ICSE) conference next month on May 17th in Vancouver, Canada. Go and register as long as slots are available. This is a great introduction if you are interested in using Pex or other test input generation tools to test your code, but you were struggling with the new concepts such as Parameterized Unit Tests.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9543900" width="1" height="1"&gt;</description></item><item><title>Pex now a DevLabs project</title><link>http://blogs.msdn.com/nikolait/archive/2008/10/24/pex-now-a-devlabs-project.aspx</link><pubDate>Fri, 24 Oct 2008 10:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9014350</guid><dc:creator>nikolait</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/9014350.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=9014350</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://blogs.msdn.com/somasegar/archive/2008/10/23/inspiring-through-innovation-devlabs.aspx" target=_blank mce_href="http://blogs.msdn.com/somasegar/archive/2008/10/23/inspiring-through-innovation-devlabs.aspx"&gt;Soma just announced&lt;/A&gt; &lt;A href="http://msdn.microsoft.com/DevLabs" target=_blank mce_href="http://msdn.microsoft.com/DevLabs"&gt;DevLabs&lt;/A&gt; (&lt;A href="http://msdn.microsoft.com/DevLabs" target=_blank mce_href="http://msdn.microsoft.com/DevLabs"&gt;http://msdn.microsoft.com/DevLabs&lt;/A&gt;), "a site dedicated to [...] software innovations for the developer community".&lt;/P&gt;
&lt;P&gt;We are proud that Pex is one of the first projects &lt;A href="http://msdn.microsoft.com/en-us/devlabs/cc950525.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/devlabs/cc950525.aspx"&gt;hosted on DevLabs&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;What does that mean for Pex?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Pex for Visual Studio Team System 2010 CTP&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;At the same time as Pex became a DevLabs project, we made Pex available as a &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=740206B5-FD17-4E7A-97D4-8AA319B01675&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=740206B5-FD17-4E7A-97D4-8AA319B01675&amp;amp;displaylang=en"&gt;Microsoft Download&lt;/A&gt; for Visual Studio Team System &lt;STRONG&gt;2010&lt;/STRONG&gt;. But before you go there to download the latest version of Pex, keep reading and let us explain this in more detail: Right now, if you download Pex from that link, it will only install if you have VS&lt;STRONG&gt;2010 &lt;/STRONG&gt;installed. The first CTP ("Community Technology Preview") of VS2010 will be distributed to attendees of this month's Professional Developers Conference (&lt;A href="http://blogs.msdn.com/nikolait/archive/2008/10/04/pex-at-pdc2008.aspx" target=_blank mce_href="http://blogs.msdn.com/nikolait/archive/2008/10/04/pex-at-pdc2008.aspx"&gt;PDC&lt;/A&gt;) in Los Angeles. Another reason to &lt;A href="http://microsoftpdc.com/Registration/" target=_blank mce_href="http://microsoftpdc.com/Registration/"&gt;go to PDC&lt;/A&gt;. As an alternative, you can still use the &lt;A href="http://research.microsoft.com/Pex/downloads.aspx" target=_blank mce_href="http://research.microsoft.com/Pex/downloads.aspx"&gt;Microsoft Research Download&lt;/A&gt; which does not require VS2010, and works great with VS2008; it is identical in terms of features.&lt;/P&gt;
&lt;P&gt;The new Microsoft Download comes under a &lt;A href="http://research.microsoft.com/Pex/MSPreReleaseLicensePex.rtf" target=_blank mce_href="http://research.microsoft.com/Pex/MSPreReleaseLicensePex.rtf"&gt;Microsoft Pre-Release Software License for Pex&lt;/A&gt;. This license is different from the Microsoft Research License agreement: It does not explicitly rule out all forms of commercial use.&lt;/P&gt;
&lt;P&gt;An excerpt from the new license: "&lt;EM&gt;&lt;B&gt;PRE-RELEASE SOFTWARE. &lt;/B&gt;This software is a pre-release version. It may not work the way a final version of the software will. We may change it for the final, commercial version. We also may not release a commercial version.&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Experiment, evaluate, and then join us in the conversation&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;As Soma said: "help us determine the direction that these projects should eventually head". As an early adopter, now is the best time for you to try out Pex and give us feedback. The Pex team is very open to suggestions, as Pex is still rapidly evolving.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;MSDN Forum for Pex&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Pex has now an &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/pex/threads/" target=_blank mce_href="http://social.msdn.microsoft.com/Forums/en-US/pex/threads/"&gt;MSDN Forum&lt;/A&gt;, where you can ask questions and start discussions.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9014350" width="1" height="1"&gt;</description></item><item><title>Pex 0.8 Released, featuring Code Digger and Stubs</title><link>http://blogs.msdn.com/nikolait/archive/2008/10/22/pex-0-8-released-featuring-code-digger-and-stubs.aspx</link><pubDate>Wed, 22 Oct 2008 23:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9011688</guid><dc:creator>nikolait</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/9011688.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=9011688</wfw:commentRss><description>&lt;P&gt;We just &lt;A href="http://research.microsoft.com/pex/downloads.aspx" target=_blank mce_href="http://research.microsoft.com/pex/downloads.aspx"&gt;released&lt;/A&gt; the most exciting iteration of &lt;A href="http://research.microsoft.com/pex/" target=_blank mce_href="http://research.microsoft.com/pex/"&gt;Pex&lt;/A&gt; to this date: version 0.8. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;: Pex is now a &lt;A class="" href="http://msdn.microsoft.com/en-us/devlabs/cc950525.aspx" mce_href="http://msdn.microsoft.com/en-us/devlabs/cc950525.aspx"&gt;DevLabs project&lt;/A&gt;, and available as a &lt;A class="" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=740206B5-FD17-4E7A-97D4-8AA319B01675&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=740206B5-FD17-4E7A-97D4-8AA319B01675&amp;amp;displaylang=en"&gt;Microsoft Download&lt;/A&gt; for Visual Studio 2010 CTP. (It won't install without it.)&lt;/P&gt;
&lt;P&gt;The &lt;A href="http://research.microsoft.com/pex/downloads.aspx" target=_blank mce_href="http://research.microsoft.com/pex/downloads.aspx"&gt;Microsoft Research download&lt;/A&gt; still comes with the &lt;A href="http://research.microsoft.com/pex/license.aspx" mce_href="http://research.microsoft.com/pex/license.aspx"&gt;Microsoft Research license&lt;/A&gt;, so you cannot use it for commercial purposes, but it's perfect if you just want to try it out, or use it for academic purposes; it targets Visual Studio 2008 Professional, but all you really need is Windows XP with .NET 2.0.&lt;/P&gt;
&lt;P&gt;Besides &lt;A href="http://research.microsoft.com/pex/releasenotes.aspx#v0.8.31021.3" target=_blank mce_href="http://research.microsoft.com/pex/releasenotes.aspx#v0.8.31021.3"&gt;lots of bug fixes and little improvements&lt;/A&gt;, this release comes with two huge innovations: &lt;A href="http://blogs.msdn.com/nikolait/archive/2008/10/21/sneak-preview-code-digger-the-new-pex-experience.aspx" target=_blank mce_href="http://blogs.msdn.com/nikolait/archive/2008/10/21/sneak-preview-code-digger-the-new-pex-experience.aspx"&gt;Code Digger&lt;/A&gt;, and &lt;A href="http://blog.dotnetwiki.org/PexGetsAStubsFrameworkISaidStubsNotMocks.aspx" target=_blank mce_href="http://blog.dotnetwiki.org/PexGetsAStubsFrameworkISaidStubsNotMocks.aspx"&gt;Stubs&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;New Experience: Code Digger&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Did you ever write some new code, change some old code, or simply look at existing code, and you were not quite sure what it was capable of? Which inputs would trigger a successful "happy" path, and which ones would be rejected? Maybe you were thinking: "If only I had a test suite..."&lt;/P&gt;
&lt;P&gt;You can have that test suite! (And you won't have to sweat for it.)&lt;/P&gt;
&lt;P&gt;We have added an entirely new way of using Pex: Just right-click somewhere in the code you are currently editing, and then Pex will analyze all the branches in the code. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerRunPexExplorations_2.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerRunPexExplorations_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=268 alt=DiggerRunPexExplorations src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerRunPexExplorations_thumb.png" width=484 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerRunPexExplorations_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Pex shows you a table of interesting input/output values, and you can save all findings as a unit test suite with a single button click.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerSaveAll_2.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerSaveAll_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=184 alt=DiggerSaveAll src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerSaveAll_thumb.png" width=483 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerSaveAll_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;There you are. Enjoy your small test suite with high code coverage that integrates with VIsual Studio Team Test!&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerTestView_2.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerTestView_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=298 alt=DiggerTestView src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerTestView_thumb.png" width=484 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex.8ReleasedforVS2008noncommercialuseon_10CDD/DiggerTestView_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;We call this new experience &lt;A href="http://blogs.msdn.com/nikolait/archive/2008/10/21/sneak-preview-code-digger-the-new-pex-experience.aspx" target=_blank mce_href="http://blogs.msdn.com/nikolait/archive/2008/10/21/sneak-preview-code-digger-the-new-pex-experience.aspx"&gt;Code Digger&lt;/A&gt;. If the short description above didn't quite make sense to you, read &lt;A href="http://blogs.msdn.com/nikolait/archive/2008/10/21/sneak-preview-code-digger-the-new-pex-experience.aspx" target=_blank mce_href="http://blogs.msdn.com/nikolait/archive/2008/10/21/sneak-preview-code-digger-the-new-pex-experience.aspx"&gt;my longer post on Code Digger&lt;/A&gt;, and check out the full &lt;A href="http://research.microsoft.com/Pex/articles/pexcodediggertutorial.pdf" target=_blank mce_href="http://research.microsoft.com/Pex/articles/pexcodediggertutorial.pdf"&gt;Code Digger tutorial&lt;/A&gt;&amp;nbsp; (it already refers to the forthcoming VS2010, but don't let that stop you).&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;New Feature: Stubs&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Also shipping in this release: &lt;A href="http://blog.dotnetwiki.org/PexGetsAStubsFrameworkISaidStubsNotMocks.aspx" target=_blank mce_href="http://blog.dotnetwiki.org/PexGetsAStubsFrameworkISaidStubsNotMocks.aspx"&gt;Stubs&lt;/A&gt; - A Simple Framework For .NET Test Stubs; also comes with a &lt;A href="http://research.microsoft.com/pex/articles/stubs.pdf" target=_blank mce_href="http://research.microsoft.com/pex/articles/stubs.pdf"&gt;manual&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;It's a no-nonsense framework to easily create and maintain lightweight implementations of interfaces and abstract classes.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Stay tuned for more: PDC is coming&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;There will be further announcements.&lt;/P&gt;
&lt;P&gt;And don't forget: Pex is at PDC! Go to our &lt;A href="http://blogs.msdn.com/nikolait/archive/2008/10/04/pex-at-pdc2008.aspx" mce_href="http://blogs.msdn.com/nikolait/archive/2008/10/04/pex-at-pdc2008.aspx"&gt;talk at PDC&lt;/A&gt; and get the latest demo at the &lt;A href="http://microsoftpdc.com/Agenda/UnSessions.aspx#msr-at-pdc" mce_href="http://microsoftpdc.com/Agenda/UnSessions.aspx#msr-at-pdc"&gt;Microsoft Research booth&lt;/A&gt;!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9011688" width="1" height="1"&gt;</description></item><item><title>Sneak Preview: Code Digger — The New Pex Experience</title><link>http://blogs.msdn.com/nikolait/archive/2008/10/21/sneak-preview-code-digger-the-new-pex-experience.aspx</link><pubDate>Tue, 21 Oct 2008 21:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9010191</guid><dc:creator>nikolait</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/9010191.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=9010191</wfw:commentRss><description>&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Do you control your code? &lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Did you ever write some new code, change some old code, or simply look at existing code, and you were not quite sure what it was capable of? Which inputs would trigger a successful "happy" path, and which ones would be rejected? Maybe you were thinking: "If only I had a test suite..."&lt;/P&gt;
&lt;P&gt;Well, be our guest, or rather &lt;A href="http://research.microsoft.com/Pex/" target=_blank mce_href="http://research.microsoft.com/Pex/"&gt;Pex&lt;/A&gt;' guest: You can have that test suite! (And you won't have to sweat for it.)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Update: &lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;You can now&amp;nbsp;&lt;A href="http://research.microsoft.com/Pex/downloads.aspx" target=_blank mce_href="http://research.microsoft.com/Pex/downloads.aspx"&gt;download&lt;/A&gt; Code Digger as part of &lt;A class="" href="http://research.microsoft.com/Pex/downloads.aspx" mce_href="http://research.microsoft.com/Pex/downloads.aspx"&gt;the latest Pex release&lt;/A&gt;. And just as a reminder: &lt;/EM&gt;&lt;EM&gt;&lt;A href="http://microsoftpdc.com/Registration/" target=_blank mce_href="http://microsoftpdc.com/Registration/"&gt;&lt;STRONG&gt;Register&lt;/STRONG&gt;&lt;/A&gt;&lt;STRONG&gt; for PDC, &lt;/STRONG&gt;&lt;A href="http://blogs.msdn.com/nikolait/archive/2008/10/04/pex-at-pdc2008.aspx" target=_blank mce_href="http://blogs.msdn.com/nikolait/archive/2008/10/04/pex-at-pdc2008.aspx"&gt;&lt;STRONG&gt;go to our talk&lt;/STRONG&gt;&lt;/A&gt;&lt;STRONG&gt; and watch the latest demo at the &lt;/STRONG&gt;&lt;A href="http://microsoftpdc.com/Agenda/UnSessions.aspx#msr-at-pdc" target=_blank mce_href="http://microsoftpdc.com/Agenda/UnSessions.aspx#msr-at-pdc"&gt;Microsoft Research &lt;STRONG&gt;booth&lt;/STRONG&gt;&lt;/A&gt;&lt;STRONG&gt;!&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;If you want to read more, we have just completed the full &lt;A href="http://research.microsoft.com/Pex/articles/pexcodediggertutorial.pdf" target=_blank mce_href="http://research.microsoft.com/Pex/articles/pexcodediggertutorial.pdf"&gt;Code Digger&lt;/A&gt; tutorial. It already refers to VS2010, but the &lt;A class="" title="Microsoft Research download" href="http://research.microsoft.com/pex/downloads.aspx" target=_blank mce_href="http://research.microsoft.com/pex/downloads.aspx"&gt;Microsoft Research download&lt;/A&gt; also works with VS2008.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Code Digging with Pex&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Ok, back to your code. Let's say you are looking at a method that capitalizes words in a string. With horror, you’ve just realized that you totally forgot to write tests for it. In fact, you even don't remember why the method has so many if-statements that treat special cases. It seems that the situations is hopeless, but wait... All you have to do is right-click on your code in the Visual Studio editor, and select "Run Pex Explorations"!&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerRunPexExplorations_2.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerRunPexExplorations_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=237 alt=DiggerRunPexExplorations src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerRunPexExplorations_thumb.png" width=427 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerRunPexExplorations_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;That will trigger a &lt;STRONG&gt;deep code analysis &lt;/STRONG&gt;using the &lt;A href="http://research.microsoft.com/Pex/wiki/Input%20Generation.html" target=_blank mce_href="http://research.microsoft.com/Pex/wiki/Input%20Generation.html"&gt;Pex engine&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;And let us repeat the main point: You start the analysis from the code, not from an already existing Unit Test, or even &lt;A href="http://research.microsoft.com/Pex/wiki/parameterized%20unit%20testing.html" target=_blank mce_href="http://research.microsoft.com/Pex/wiki/parameterized%20unit%20testing.html"&gt;Parameterized Unit Test&lt;/A&gt;! No test suite needed. No test project needed. The only reason we are using the word "test" so often because we want to stress that you don't need any.&lt;/P&gt;
&lt;P&gt;So, what do we get? A &lt;STRONG&gt;table with inputs and outputs &lt;/STRONG&gt;that cover all the successful and failing corner cases. To this end, Pex analyzed all the branches in the code to figure out what interested values are. The code we were "digging" here only distinguished lower-case characters, upper-case characters, and punctuation characters. (This is the same kind of table that Pex produces when you analyze &lt;A href="http://research.microsoft.com/Pex/wiki/parameterized%20unit%20testing.html" target=_blank mce_href="http://research.microsoft.com/Pex/wiki/parameterized%20unit%20testing.html"&gt;Parameterized Unit Tests&lt;/A&gt;.)&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerTestTable_2.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerTestTable_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=322 alt=DiggerTestTable src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerTestTable_thumb.png" width=635 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerTestTable_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Okay, that's nice. You can look at all the cases and check whether they make sense to you. You can use all the already existing Pex features. For example, with two mouse clicks, you could &lt;A href="http://research.microsoft.com/Pex/wiki/Fix%20It.html" target=_blank mce_href="http://research.microsoft.com/Pex/wiki/Fix%20It.html"&gt;let Pex fix your code&lt;/A&gt; to throw an ArgumentNullException instead of the NullReferenceException.&lt;/P&gt;
&lt;P&gt;But there is more. Remember, we promised you a test suite...&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Code Digging for Gold: Test Suites for Free!&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You can select one, several, or simply all rows, and click on the "Save..." button. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerSaveAll_2.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerSaveAll_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=238 alt=DiggerSaveAll src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerSaveAll_thumb.png" width=630 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerSaveAll_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Pex will create an entire test project, and generate C# code for all selected rows as unit test.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/diggersolutionexplorer_2.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/diggersolutionexplorer_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=232 alt=diggersolutionexplorer src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/diggersolutionexplorer_thumb.png" width=351 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/diggersolutionexplorer_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Integration with Visual Studio Team Test&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;And what's best: The generated tests integrate perfectly with the Visual Studio Team Test unit test framework, showing up in Visual Studio's Test View window.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerTestView_2.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerTestView_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=309 alt=DiggerTestView src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerTestView_thumb.png" width=502 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/SneakPreviewCodeDiggerTheNewPexExperienc_14A2D/DiggerTestView_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Now you can leverage all unit testing features that come with Visual Studio. For example, you can let Visual Studio collect code coverage information. Or, if you wonder how a line in the code can be triggered, you can set a breakpoint in that line, and run the test suite under the debugger. It's that easy. With the Pex Code Digger, you don't have to write a test driver yourself!&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Regression Test Suite&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You might wonder: Besides debugging issues right away, what is this generated test suite actually good for? We thought about that too. Each of the generated tests contains a line that asserts the behavior that Pex observed today, for example:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4"&gt;
&lt;DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; [TestMethod]&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt; [PexGeneratedBy(&lt;SPAN style="COLOR: #0000ff"&gt;typeof&lt;/SPAN&gt;(StringExtensionsTest))]&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; Capitalize11()&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt; {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; s = &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.Capitalize(&lt;SPAN style="COLOR: #006080"&gt;"p:p"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt;     Assert.AreEqual&amp;lt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&amp;gt;(&lt;SPAN style="COLOR: #006080"&gt;"P_P"&lt;/SPAN&gt;, s);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt; }&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;After saving today's tests, when you ever change the code again in the future, you will have an excellent regression test suite that will identify the breaking changes.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Does this replace traditional testing?&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Not really. With Code Digger, you have to &lt;STRONG&gt;manually &lt;/STRONG&gt;inspect each generated test case to check whether your code does what you want it do to. In contrast, Unit Tests, or even better, &lt;A href="http://research.microsoft.com/Pex/wiki/parameterized%20unit%20testing.html" target=_blank mce_href="http://research.microsoft.com/Pex/wiki/parameterized%20unit%20testing.html"&gt;Parameterized Unit Test&lt;/A&gt;, are an excellent way to describe &lt;STRONG&gt;programmatically &lt;/STRONG&gt;what your code is supposed to do. Code Digger and (Parameterized) Unit Testing are complementary, and one doesn't make the other obsolete.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;The end&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;That's all for this post; keep watching for further announcements, or read the full &lt;A href="http://research.microsoft.com/Pex/articles/pexcodediggertutorial.pdf" target=_blank mce_href="http://research.microsoft.com/Pex/articles/pexcodediggertutorial.pdf"&gt;Code Digger&lt;/A&gt; tutorial.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9010191" width="1" height="1"&gt;</description></item><item><title>Pex at PDC2008</title><link>http://blogs.msdn.com/nikolait/archive/2008/10/04/pex-at-pdc2008.aspx</link><pubDate>Sat, 04 Oct 2008 10:19:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8976195</guid><dc:creator>nikolait</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/8976195.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=8976195</wfw:commentRss><description>&lt;p&gt;We are very excited to announce that &lt;a href="http://research.microsoft.com/pex"&gt;&lt;strong&gt;Pex&lt;/strong&gt;&lt;/a&gt; has a session at &lt;a href="http://www.microsoftpdc.com/"&gt;PDC 2008&lt;/a&gt;. The session combines two topics: how to write and statically check code contracts in the spirit of &lt;a href="http://research.microsoft.com/SpecSharp/"&gt;Spec#&lt;/a&gt;, and how to generate test cases with Pex directly from your product code. We'll demo new cool features you haven't seen before.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sessions.microsoftpdc.com/"&gt;Book it now in your conference agenda!&lt;/a&gt; (look for &lt;em&gt;Research &lt;/em&gt;in the session list, or search for &lt;em&gt;Pex&lt;/em&gt;).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.dotnetwiki.org/images/PexatPDC2008Wewillbethere_D792/image.png"&gt;&lt;img title="image" height="366" alt="image" src="http://blog.dotnetwiki.org/images/PexatPDC2008Wewillbethere_D792/image_thumb.png" width="482" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;See you there and don&amp;#8217;t forget to swing by the Microsoft Research booth where we'll demo Pex just for you.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8976195" width="1" height="1"&gt;</description></item><item><title>Pex 0.7 Released</title><link>http://blogs.msdn.com/nikolait/archive/2008/09/22/pex-0-7-released.aspx</link><pubDate>Tue, 23 Sep 2008 01:35:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8961647</guid><dc:creator>nikolait</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/8961647.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=8961647</wfw:commentRss><description>&lt;p&gt;We just &lt;a href="http://research.microsoft.com/Pex/downloads.aspx"&gt;published Pex 0.7&lt;/a&gt;. This update is mainly a maintenance release. We have been working on fixing bugs, those reported by our users, as well as many others we found while using Pex internally. There are a few &lt;a href="http://research.microsoft.com/Pex/releasenotes.aspx"&gt;breaking changes&lt;/a&gt; (mainly renamings), and a few improvements under the cover.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Patterns for Parameterized Unit Testing&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Writing good parameterized unit tests is hard. We have started to collect a set of patterns how to write good parameterized unit tests, and avoid bad ones. Peli gives an introduction to &lt;a href="http://research.microsoft.com/Pex/articles/pexpatterns.pdf"&gt;our new paper with patterns&lt;/a&gt; in &lt;a href="http://blog.dotnetwiki.org/ParameterizedUnitTestPatternsDraft.aspx"&gt;his blog&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Better Reasoning&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Pex now knows a bit more about enums, so that you can write assumptions such as the following.&lt;/p&gt;  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; [PexMethod]&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; TestWithEnumParameter(MyEnum &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     PexAssume.IsTrue(Enum.IsDefined(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(MyEnum), &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;));&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// ... use value in test ...&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The assumption above filters out those enum values which are not defined.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Better Exploration Strategies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In addition to such improvements in local reasoning, we also worked on better global reasoning, i.e., searching more effectively for interesting feasible execution paths.&lt;/p&gt;

&lt;p&gt;Together with &lt;a href="http://people.engr.ncsu.edu/txie/"&gt;Tao Xie&lt;/a&gt;, who visited us from North Carolina State University, we developed a search strategy based on the idea of &lt;em&gt;fitness&lt;/em&gt;. The result is a paper [&lt;a href="ftp://ftp.research.microsoft.com/pub/tr/TR-2008-123.pdf"&gt;PDF&lt;/a&gt;], and we also published the &lt;a href="http://www.codeplex.com/Pex/Wiki/View.aspx?title=Fitnex"&gt;source code&lt;/a&gt; on CodePlex. If you dare, you could try to write your search strategy, plug it into Pex, and see if your strategy solve problems that Pex couldn't solve before!&lt;/p&gt;

&lt;p&gt;For example, before we integrated the the fitness-based search strategy, Pex had a really hard time to find the &amp;quot;bug&amp;quot; hidden in the following test.&lt;/p&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; [PexMethod]&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; FitnessTest([PexAssumeNotNull]&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;[] x)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; y = 0;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i = 0; i &amp;lt; x.Length; i++)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (x[i] == i)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;             y++;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (y&amp;gt;=10)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Exception(&lt;span style="color: #006080"&gt;&amp;quot;bug&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;(I realize that this test doesn't do anything useful. It's just the essence of a testing problem.) You need to come up with a very particular input array to hit the &amp;quot;bug&amp;quot;. The problem here for Pex is that the variable y, whose value decides whether we hit the bug, is related to the test inputs in a very indirect fashion. To better attack those kinds of problems, Pex now uses the notion of &lt;em&gt;fitness &lt;/em&gt;to guide the search, here towards those test inputs which cause y to be closer and closer to 10.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8961647" width="1" height="1"&gt;</description></item><item><title>Pex 0.6 Released</title><link>http://blogs.msdn.com/nikolait/archive/2008/08/06/pex-0-6-released.aspx</link><pubDate>Wed, 06 Aug 2008 20:30:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8838219</guid><dc:creator>nikolait</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/8838219.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=8838219</wfw:commentRss><description>&lt;p&gt;We just &lt;a href="http://research.microsoft.com/pex/downloads.aspx"&gt;released another milestone&lt;/a&gt; for &lt;a href="http://research.microsoft.com/pex"&gt;Pex&lt;/a&gt;: version 0.6, still under the &lt;a href="http://research.microsoft.com/pex/license.aspx"&gt;Microsoft Research License&lt;/a&gt;. Ideally you have Visual Studio 2008 Professional to get the full experience, but all you really need is .NET 2.0. Take a look at exercise 3 in the &lt;a href="http://research.microsoft.com/pex/articles/pextutorial.pdf"&gt;tutorial&lt;/a&gt; to get started in Visual Studio 2008 Professional, and exercise 4 shows you how to use the command-line.&lt;/p&gt;  &lt;p&gt;There have been a bunch of changes that we documented in the &lt;a href="http://research.microsoft.com/pex/releasenotes.aspx"&gt;release notes&lt;/a&gt;, most notably some UI polishing, and finally, the ability to install Pex under a 64-bit Windows operating system!&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;strong&gt;64-bit support: Pex 0.6 installs on 64-bit Windows (but cannot analyze 64-bit-only code)&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;We have taken some precautions that all processes that Pex launches are 32-bit processes. Since Pex actually runs your code during the analysis to generate test inputs, this will only work when the code that you want to analyze is marked as &amp;quot;Any CPU&amp;quot; or &amp;quot;x86&amp;quot;, but not &amp;quot;X64&amp;quot; (or &amp;quot;Itanium&amp;quot;). This is normally not an issue.&lt;/p&gt;  &lt;p&gt;And you can run the generated tests on any platform (assuming your test framework supports other platforms; note that MSTest only supports 32-bit as well).&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;strong&gt;Why Pex cares about 32-bit vs. 64-bit&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;Pex analyzes .NET code, and you would think that it shouldn't matter for such a tool whether it runs in a 32-bit or 64-bit environment. The only difference should be how many bytes a pointer/object reference occupies, and a .NET program cannot observe such implementation details, right?&lt;/p&gt;  &lt;p&gt;Indeed, it is true that most safe .NET applications couldn't care less about the different pointer sizes. &lt;/p&gt;  &lt;p&gt;But Pex can not only analyze safe .NET code, but also unsafe .NET code. (In fact, many of the methods of the .NET framework are implemented using unsafe code, such as string.Equals.) In unsafe .NET code, conversions between integers and pointers happen all the time. Some conversions are explicit, and many more are implicit in the code generated by the C#.&lt;/p&gt;  &lt;p&gt;To keep things simple, let me show you an example with an explicit conversion. The following is a parameterized unit test that has quite different behaviors depending on whether it is running in 32-bit or 64-bit mode. Can you guess in which mode the &amp;quot;bug&amp;quot; can occur?&lt;/p&gt;  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; [PexMethod]&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;unsafe&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; TestX86(&lt;span style="color: #0000ff"&gt;long&lt;/span&gt; x)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;void&lt;/span&gt;* p = (&lt;span style="color: #0000ff"&gt;void&lt;/span&gt;*)x;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (p == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; x == (1L&amp;lt;&amp;lt;32))&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Exception(&lt;span style="color: #006080"&gt;&amp;quot;bug!&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Answer: Only in 32-bit mode. There, the conversion from &lt;font face="Consolas"&gt;long&lt;/font&gt; to &lt;font face="Consolas"&gt;(void*)&lt;/font&gt; ignores the upper 32-bits, which can then be freely assigned in any way. Pex finds the following in 32-bit mode:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.6Released_14379/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="139" alt="image" src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/Pex0.6Released_14379/image_thumb.png" width="536" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;In words: When calling &lt;font face="Consolas"&gt;TestX86&lt;/font&gt; with the value 4294967296, the exception is thrown. In 32-bit mode, that is. In 64-bit mode, the exception cannot be thrown for any value.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;Does the difference in behavior between 32-bit and 64-bit really matter in practice?&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;For most purposes, probably not. (Unless you are writing unsafe code, and you are concerned about buffer-overflows and such.) In any case, you can just take the generated test suite and run it on any platform you wish.&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;&lt;u&gt;&lt;strong&gt;Why don't you just recompile Pex for 64-bit then?&lt;/strong&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;We were asked on our mailing list why we couldn't just recompile Pex for 64-bit. As you have seen above, it is not that simple, since Pex and its constraint solver needs to reason about different constraints depending on the bitness. All the explicit and implicit conversions in the .NET instruction have different meanings.&lt;/p&gt;

&lt;p&gt;But a true 64-bit version of Pex is not that distant: My main development machine runs 64-bit Vista, and I implemented all relevant conversion for 64-bit as well. The main problem is that our automated testing process for Pex runs on a 32-bit Vista machine. Testing Pex itself for both 32-bit and 64-bit environments would double our testing matrix.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8838219" width="1" height="1"&gt;</description></item><item><title>Fun with the ResourceReader</title><link>http://blogs.msdn.com/nikolait/archive/2008/06/04/fun-with-the-resourcereader.aspx</link><pubDate>Thu, 05 Jun 2008 02:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8574254</guid><dc:creator>nikolait</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/8574254.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=8574254</wfw:commentRss><description>&lt;P&gt;After we &lt;A href="http://blogs.msdn.com/nikolait/archive/2008/05/21/pex-0-5-released.aspx" target=_blank mce_href="http://blogs.msdn.com/nikolait/archive/2008/05/21/pex-0-5-released.aspx"&gt;released&lt;/A&gt; &lt;A href="http://research.microsoft.com/pex" target=_blank mce_href="http://research.microsoft.com/pex"&gt;Pex&lt;/A&gt;&amp;nbsp;recently, I came across a couple of interesting blog posts of people who tried out Pex, for example &lt;A href="http://blog.benhall.me.uk/2008/05/microsoft-pex-05-released.html" target=_blank mce_href="http://blog.benhall.me.uk/2008/05/microsoft-pex-05-released.html"&gt;Ben Hall&lt;/A&gt;, &lt;A href="http://dotnet.org.za/pieter/archive/2008/06/04/some-more-on-pex.aspx" target=_blank mce_href="http://dotnet.org.za/pieter/archive/2008/06/04/some-more-on-pex.aspx"&gt;Peter&lt;/A&gt;, and &lt;A href="http://plainoldstan.blogspot.com/2008/05/why-to-use-pex-sample-1-reason-1.html" target=_blank mce_href="http://plainoldstan.blogspot.com/2008/05/why-to-use-pex-sample-1-reason-1.html"&gt;Stan&lt;/A&gt;. They all ran Pex on a small example. In this post, I want to run Pex on a more complicated piece of code: The .Net &lt;A href="http://msdn.microsoft.com/en-us/library/system.resources.resourcereader.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.resources.resourcereader.aspx"&gt;ResourceReader&lt;/A&gt;, and all the other classes which it uses under the hood.&lt;/P&gt;
&lt;P&gt;The ResourceReader takes a stream of data, and splits it up into individual chunks that represent resources. In that sense, the ResourceReader is a big parser. &lt;/P&gt;
&lt;H3&gt;&lt;U&gt;Writing a parameterized unit test&lt;/U&gt;&lt;/H3&gt;
&lt;P&gt;I started by creating a new C# test project in Microsoft Visual Studio, and adding a reference to Microsoft.Pex.Framework. (If you try this at home, you need to &lt;A href="http://research.microsoft.com/Pex/downloads.aspx" target=_blank mce_href="http://research.microsoft.com/Pex/downloads.aspx"&gt;install Pex&lt;/A&gt; first, of course.)&lt;/P&gt;
&lt;P&gt;Then I wrote a very simple parameterized unit test for the resource reader. It takes any (non-null) array of bytes, creates an &lt;A href="http://msdn.microsoft.com/en-us/library/system.io.unmanagedmemorystream.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.io.unmanagedmemorystream.aspx"&gt;UnmanagedMemoryStream&lt;/A&gt; with the bytes, and then decodes it with the ResourceReader. It's not a particular expressive test, since it doesn't contain any assertions. All this test is really saying is that, no matter what the test inputs are, the code shouldn't throw any exception. (No exception at all? I'll investigate this in more detail later.)&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;    [PexClass, TestClass]&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;partial&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; ResourceReaderTest&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;    {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;        [PexMethod]&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   5:  &lt;/SPAN&gt;        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;unsafe&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; ReadEntries([PexAssumeNotNull]&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;[] data)&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   6:  &lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   7:  &lt;/SPAN&gt;            &lt;SPAN class=kwrd&gt;fixed&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;* p = data)&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   8:  &lt;/SPAN&gt;                &lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; (UnmanagedMemoryStream stream =&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   9:  &lt;/SPAN&gt;                    &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; UnmanagedMemoryStream(p, data.Length))&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  10:  &lt;/SPAN&gt;                {&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  11:  &lt;/SPAN&gt;                    ResourceReader reader = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; ResourceReader(stream);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  12:  &lt;/SPAN&gt;                    &lt;SPAN class=kwrd&gt;foreach&lt;/SPAN&gt; (&lt;FONT color=#000000&gt;&lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; entry &lt;/FONT&gt;&lt;SPAN class=kwrd&gt;in&lt;/SPAN&gt; reader) { /* just reading */ }&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  13:  &lt;/SPAN&gt;                }&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  14:  &lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  15:  &lt;/SPAN&gt;    }&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;P&gt;Let's run Pex.&lt;/P&gt;
&lt;H3&gt;&lt;U&gt;Run Pex Exploration&lt;/U&gt;&lt;/H3&gt;
&lt;P&gt;I can now let Pex analyze this parameterized unit test in-depth by right-clicking on the parameterized unit test, and selecting &lt;STRONG&gt;Run Pex Exploration&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_4.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=102 alt=image src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_1.png" width=228 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;(I am running our latest internal Pex bits, and we just renamed the "Pex It" menu item to "Run Pex Exploration". So if you just see a "Pex It" menu item, use that.)&lt;/P&gt;
&lt;P&gt;Pex now &lt;A href="http://research.microsoft.com/Pex/wiki/Input%20Generation.html" target=_blank mce_href="http://research.microsoft.com/Pex/wiki/Input%20Generation.html"&gt;generates test inputs&lt;/A&gt;. In a nutshell, Pex runs the code, monitors what it's doing, and uses a constraint solver to determine more relevant test inputs that will take the program along different execution paths.&lt;/P&gt;
&lt;P&gt;That sounds great, but the result is a little bit disappointing: Pex reports only two test inputs: An empty array, and an array with one element that is zero.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_8.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_8.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=159 alt=image src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_3.png" width=761 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;(Again, I have to say that I am running our latest internal Pex bits. If you see a big black empty region in the lower right part of the Pex Results, titled with "dynamic coverage", then you can get rid of this waste of screen real-estate by pressing the button that I circled in red:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_34.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_34.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=50 alt=image src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_16.png" width=758 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_16.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;We won't show this "dynamic coverage" graph by default anymore. I might talk more about this feature in the future. And now, back to the ResourceReader.)&lt;/P&gt;
&lt;P&gt;Pex tells us in bold letters on red ground that it encountered &lt;STRONG&gt;3 Uninstrumented Methods&lt;/STRONG&gt;. &lt;/P&gt;
&lt;P&gt;What does that mean? Well, Pex performs a dynamic analysis, which means that it runs the code, and then Pex monitors what the code is actually doing. However, Pex doesn't monitor all code, but only code that Pex instruments. Pex doesn't instrument all code by default, since the instrumentation and the monitoring comes with a huge performance overhead. And often it is not necessary to monitor all the code that is running. For example, when you want to test your algorithm, and your algorithm happens to write its progress to the console, then you still only want to test your algorithm, but not all the supporting code that hides behind Console.WriteLine. &lt;/P&gt;
&lt;H3&gt;&lt;U&gt;Configuring what Pex analyzes: Instrumentation settings&lt;/U&gt;&lt;/H3&gt;
&lt;P&gt;But back to the ResourceReader: Let's click on the &lt;STRONG&gt;3 Uninstrumented Methods&lt;/STRONG&gt; warning.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_10.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_10.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=172 alt=image src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_4.png" width=759 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_4.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;We see that Pex neither instrumented UnmanagedMemoryStream nor ResourceReader. No wonder that Pex' analysis didn't find any really interesting test inputs! Pex also didn't monitor what happened in a call to GC.SuppressFinalize, but this relates to the .NET garbage collector, and probably isn't so important. (In fact, Pex has a built-in list of classes which don't need to be monitored, and we might add the GC class to this list in the future.)&lt;/P&gt;
&lt;P&gt;Let's select UnmanagedMemoryStream..ctor (".ctor" is the generic .NET name for constructors),&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_12.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_12.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=174 alt=image src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_5.png" width=810 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_5.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;and click on &lt;STRONG&gt;Instrument type&lt;/STRONG&gt;, and repeat for ResourceReader..ctor. For GC.SuppressFinalize, I click on &lt;STRONG&gt;Ignore uninstrumented method &lt;/STRONG&gt;instead. Pex persists my choices as assembly-level attributes in a new file called PexAssembyInfo.cs in the Properties folder. It now looks like this:&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; Microsoft.Pex.Framework.Instrumentation;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.IO;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Resources;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; Microsoft.Pex.Framework.Suppression;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   5:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   6:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   7:  &lt;/SPAN&gt;[assembly: PexInstrumentType(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(UnmanagedMemoryStream))]&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   8:  &lt;/SPAN&gt;[assembly: PexInstrumentType(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(ResourceReader))]&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   9:  &lt;/SPAN&gt;[assembly: PexSuppressUninstrumentedMethodFromType(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(GC))]&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;
I let Pex run again. You can re-run the last exploration by clicking on the Play-button:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_16.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_16.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=46 alt=image src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_7.png" width=408 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_7.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Pex did a little bit more this time -- three test cases! And another &lt;STRONG&gt;7 Uninstrumented Methods&lt;/STRONG&gt; warnings...&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_18.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_18.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=174 alt=image src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_8.png" width=751 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_8.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;What are the uninstrumented methods this time? &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_20.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_20.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=245 alt=image src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_9.png" width=754 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_9.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;As you can see, Pex' analysis already proceeded much deeper into the code, and now Pex hits all kinds of other methods. Most of the methods sound relevant. So I repeat the game, and let Pex instrument all of the types. And then I let Pex run again. Boom! Pex still reports some uninstrumented methods (and lots of other things which I'll explain another time), but Pex also doesn't stop so quickly anymore. Instead, Pex is having a ball and it keeps producing more and more test cases:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_22.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_22.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=338 alt=image src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_10.png" width=795 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_10.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;(If you run this example yourself, the precise results you get will vary. There is some non-deterministic code involved in the analysis.)&lt;/P&gt;
&lt;P&gt;Pex even managed to produce &lt;STRONG&gt;a valid resource file&lt;/STRONG&gt;! (here, row 215 with the green checkmark)&lt;/P&gt;
&lt;P&gt;When you double-click on any row, Pex shows the generated unit test code. Here is the valid resource file:&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;        [TestMethod]&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;        [PexGeneratedBy(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(ResourceReaderTest))]&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; ReadEntriesByte_20080604_134738_032()&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   5:  &lt;/SPAN&gt;            &lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;[] bs0 = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;[55];&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   6:  &lt;/SPAN&gt;            bs0[0] = (&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;)206;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   7:  &lt;/SPAN&gt;            bs0[1] = (&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;)202;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   8:  &lt;/SPAN&gt;            bs0[2] = (&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;)239;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   9:  &lt;/SPAN&gt;            bs0[3] = (&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;)190;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  10:  &lt;/SPAN&gt;            bs0[7] = (&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;)64;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  11:  &lt;/SPAN&gt;            bs0[12] = (&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;)2;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  12:  &lt;/SPAN&gt;            bs0[20] = (&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;)7;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  13:  &lt;/SPAN&gt;            bs0[24] = (&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;)128;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  14:  &lt;/SPAN&gt;            bs0[25] = (&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;)128;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  15:  &lt;/SPAN&gt;            bs0[32] = (&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;)4;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  16:  &lt;/SPAN&gt;            &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.ReadEntries(bs0);&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  17:  &lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;The resource file is 55 bytes long, and most bytes are zero, the default value of the byte type. All values which are not zero were carefully chosen by Pex to pass all the file-validation code of the ResourceReader.&lt;/P&gt;
&lt;H3&gt;
&lt;P&gt;&lt;U&gt;Configuring the test oracle: Allowed exceptions&lt;/U&gt;&lt;/P&gt;&lt;/H3&gt;
&lt;P&gt;All the other rows are tagged with an ugly red cross, indicating that the test failed. Did these tests really fail? Let's see. In all cases, the code either throws a ArgumentNullException, ArgumentException, BadImageFormatException, IOException, NotSupportedException, or a FormatException. &lt;/P&gt;
&lt;P&gt;These exceptions don't sound so unreasonable, considering that Pex tried obviously ill-formed test inputs in the course of its exploration.&lt;/P&gt;
&lt;P&gt;If you look around the documentation of the ResourceReader (&lt;A href="http://msdn.microsoft.com/en-us/library/9w9kac55.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/9w9kac55.aspx"&gt;here&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/ddth8hta.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ddth8hta.aspx"&gt;here&lt;/A&gt;, and &lt;A href="http://msdn.microsoft.com/en-us/library/system.resources.resourcereader.getresourcedata.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.resources.resourcereader.getresourcedata.aspx"&gt;here&lt;/A&gt;), you will find that in fact most of these exceptions are documented somewhere (although the documentation could be more explicit, and it's missing NotSupportedException).&lt;/P&gt;
&lt;P&gt;I can inform Pex that these exceptions are okay. The easiest way to do that is to select a failing test case in the table, and then click on &lt;STRONG&gt;Allow It&lt;/STRONG&gt;. Again, my choice is persisted as attributes in PexAssemblyInfo.cs:&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;[assembly: PexAllowedExceptionFromAssembly(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(ArgumentNullException), &lt;SPAN class=str&gt;"mscorlib"&lt;/SPAN&gt;)]&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;[assembly: PexAllowedExceptionFromAssembly(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(BadImageFormatException), &lt;SPAN class=str&gt;"mscorlib"&lt;/SPAN&gt;)]&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;[assembly: PexAllowedExceptionFromAssembly(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(ArgumentException), &lt;SPAN class=str&gt;"mscorlib"&lt;/SPAN&gt;)]&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;[assembly: PexAllowedExceptionFromAssembly(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(NotSupportedException), &lt;SPAN class=str&gt;"mscorlib"&lt;/SPAN&gt;)]&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   5:  &lt;/SPAN&gt;[assembly: PexAllowedExceptionFromAssembly(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(IOException), &lt;SPAN class=str&gt;"mscorlib"&lt;/SPAN&gt;)]&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   6:  &lt;/SPAN&gt;[assembly: PexAllowedExceptionFromAssembly(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(FormatException), &lt;SPAN class=str&gt;"mscorlib"&lt;/SPAN&gt;)]&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_32.png" mce_href="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_32.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=279 alt=image src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_15.png" width=757 border=0 mce_src="http://blogs.msdn.com/blogfiles/nikolait/WindowsLiveWriter/FunwiththeResourceReader_B9C6/image_thumb_15.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;When you run Pex again, all the exceptions that are marked as allowed are now tagged with friendly green checkmarks, indicating that they passed.&lt;/P&gt;
&lt;P&gt;But what is that? An OverflowException... (here, the red cross in row 98) Yet another undocumented exception...&lt;/P&gt;
&lt;H3&gt;&lt;U&gt;What can we learn from this exercise?&lt;/U&gt;&lt;/H3&gt;
&lt;P&gt;You have seen how to configure code instrumentation settings, and how to tell Pex that certain exceptions are okay.&lt;/P&gt;
&lt;P&gt;But I think there is a much more interesting insight: By using Pex, we discovered some unexpected ways how some complicated library code behaves. Library code that we build our applications on. Documentation will always be imperfect, and we have to test our applications to make sure that we everything works correctly together. By using a white-box testing tool like Pex, that tried many relevant test inputs and not just one exemplary test input, we discovered behaviors (here, exceptions) we were not aware of before!&lt;/P&gt;
&lt;H3&gt;&lt;U&gt;Stay tuned for more&lt;/U&gt;&lt;/H3&gt;
&lt;P&gt;That's it for today. Another time I might talk about the constraints that Pex had to solve to create a valid resource file, how to get an idea about how much code analyzed, how to visualize that Pex makes progress, and how to write more expressive parameterized unit tests.&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/P&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8574254" width="1" height="1"&gt;</description></item><item><title>Pex 0.5 Released</title><link>http://blogs.msdn.com/nikolait/archive/2008/05/21/pex-0-5-released.aspx</link><pubDate>Thu, 22 May 2008 04:26:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8530823</guid><dc:creator>nikolait</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/nikolait/comments/8530823.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nikolait/commentrss.aspx?PostID=8530823</wfw:commentRss><description>&lt;p&gt;Today &lt;a href="http://research.microsoft.com/pex/downloads.aspx" target="_blank"&gt;we released&lt;/a&gt; the first version of &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt; under a &lt;a href="http://research.microsoft.com/pex/license.aspx" target="_blank"&gt;Microsoft Research License&lt;/a&gt;. Ideally you have Visual Studio 2008 Professional to get the full experience, but all you really need is .NET 2.0.&lt;/p&gt; &lt;p&gt;We even wrote a &lt;a href="http://research.microsoft.com/pex/articles/pextutorial.pdf" target="_blank"&gt;tutorial&lt;/a&gt;. While it's quite long, exercise 3 helps you to get started with Visual Studio 2008 Professional, and exercise 4 shows you how to use the command-line.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;What is Pex?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;a title="Pex" href="http://research.microsoft.com/projects/pex" target="_blank"&gt;&lt;img src="http://research.microsoft.com/projects/pex/Images/PexWeb.png"&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Pex generates test inputs &lt;/strong&gt;that cover all, or at least many of the corner cases in your .NET code. These test inputs are plugged into &lt;strong&gt;parameterized&lt;em&gt; &lt;/em&gt;unit test &lt;/strong&gt;that you write. The result is a small unit test suite, where each unit test calls the parameterized unit test with particular test inputs. There is a great &lt;a href="http://research.microsoft.com/pex/default.aspx" target="_blank"&gt;picture on our main Pex page&lt;/a&gt; that illustrates this process.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Pex supports other unit test frameworks &lt;/strong&gt;since the unit tests that Pex generates can be executed by other unit test frameworks without Pex. Pex comes with support for MSTest, the unit test framework of Visual Studio, out of the box. For support for other unit test frameworks, please look at the &lt;a href="http://www.codeplex.com/pex" target="_blank"&gt;Pex Extensions&lt;/a&gt; project.&lt;/p&gt; &lt;p&gt;Parameterized unit tests have been around for quite some time already, under several names -- row tests, data-driven tests, theories, etc.&lt;/p&gt; &lt;p&gt;What is really unique about &lt;strong&gt;Pex &lt;/strong&gt;is that it &lt;strong&gt;analyzes your .NET code, instruction by instruction&lt;/strong&gt;, to understand what your code is doing. Then, in a fully automatic way, Pex computes relevant test inputs that &lt;strong&gt;trigger the corner cases of the code&lt;/strong&gt;. When you write assertions, Pex will try to come up with test inputs that cause an assertion to fail.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Is Pex a new Microsoft product?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;No, it's a prototype from Microsoft Research, developed mainly by two people. I started Pex in 2005, and &lt;a href="http://research.microsoft.com/~jhalleux/" target="_blank"&gt;Peli de Halleux&lt;/a&gt; joined the Pex team in 2006. Pex leverages other cool Microsoft Research technology, in particular the constraint solver &lt;a href="http://research.microsoft.com/projects/z3" target="_blank"&gt;Z3&lt;/a&gt;. We know that Pex has many rough edges, its version number is 0.5 for a reason.&lt;/p&gt; &lt;p&gt;Pex illustrates our vision how testing can be more powerful (and fun), without the difficulties of &lt;a href="http://research.microsoft.com/SpecSharp/" target="_blank"&gt;proving programs correct&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;At this point we are mainly looking for feedback, and we want to see what it can do for other people.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Final Thoughts&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;To ask questions, get help, or just give feedback, please take a look at our &lt;a href="http://research.microsoft.com/pex/community.aspx" target="_blank"&gt;mailing lists&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;While Peli has &lt;a href="http://blog.dotnetwiki.org/" target="_blank"&gt;blogged&lt;/a&gt; about Pex before, this is my first post. Stay tuned for more in-depth information on Pex at this place. I'll also talk about its history, and the other more or less related research projects I worked on in the past (&lt;a href="http://research.microsoft.com/fse/asml/" target="_blank"&gt;AsmL&lt;/a&gt;, &lt;a href="http://research.microsoft.com/specexplorer/" target="_blank"&gt;Spec Explorer&lt;/a&gt;, &lt;a href="http://research.microsoft.com/research/pubs/view.aspx?type=Technical Report&amp;amp;id=916" target="_blank"&gt;XRT&lt;/a&gt;).&lt;/p&gt; &lt;p&gt;Hope you have some fun with &lt;a href="http://research.microsoft.com/pex/downloads.aspx" target="_blank"&gt;Pex&lt;/a&gt;,&lt;br&gt;Nikolai&lt;/p&gt; &lt;p&gt;&lt;font size="1"&gt;Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8530823" width="1" height="1"&gt;</description></item></channel></rss>