次の方法で共有


Pex 0.7 Released

We just published Pex 0.7. 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 breaking changes (mainly renamings), and a few improvements under the cover.

Patterns for Parameterized Unit Testing

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 our new paper with patterns in his blog.

Better Reasoning

Pex now knows a bit more about enums, so that you can write assumptions such as the following.

    1: [PexMethod]
    2: public void TestWithEnumParameter(MyEnum value)
    3: {
    4:     PexAssume.IsTrue(Enum.IsDefined(typeof(MyEnum), value));
    5:     // ... use value in test ...
    6: }

The assumption above filters out those enum values which are not defined.

Better Exploration Strategies

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.

Together with Tao Xie, who visited us from North Carolina State University, we developed a search strategy based on the idea of fitness. The result is a paper [PDF], and we also published the source code 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!

For example, before we integrated the the fitness-based search strategy, Pex had a really hard time to find the "bug" hidden in the following test.

    1: [PexMethod]
    2: public void FitnessTest([PexAssumeNotNull]int[] x)
    3: {
    4:     int y = 0;
    5:     for (int i = 0; i < x.Length; i++)
    6:         if (x[i] == i)
    7:             y++;
    8:     if (y>=10)
    9:         throw new Exception("bug");
   10: }

(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 "bug". 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 fitness to guide the search, here towards those test inputs which cause y to be closer and closer to 10.

Comments

  • Anonymous
    September 22, 2008
    PingBack from http://www.easycoded.com/pex-07-released/

  • Anonymous
    September 22, 2008
    I&#39;ve been so busy over the last couple of weeks that I completely missed the release of Pex 0.7 as