Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2010 为什么运行Pex探索会导致忽略以前Pex生成的测试方法?_Visual Studio 2010_C# 4.0_Pex - Fatal编程技术网

Visual studio 2010 为什么运行Pex探索会导致忽略以前Pex生成的测试方法?

Visual studio 2010 为什么运行Pex探索会导致忽略以前Pex生成的测试方法?,visual-studio-2010,c#-4.0,pex,Visual Studio 2010,C# 4.0,Pex,正在测试的代码: public class TestReader { public string Content { get; private set; } public void LoadFile(string fileName) { var content = FileSystem.ReadAllText(fileName); if (!content.StartsWith("test")) throw new

正在测试的代码:

public class TestReader
{
    public string Content { get; private set; }

    public void LoadFile(string fileName)
    {
        var content = FileSystem.ReadAllText(fileName);
        if (!content.StartsWith("test"))
            throw new ArgumentException("invalid file");
        this.Content = content;
    }
}

public static class FileSystem
{
    public static string ReadAllText(string fileName)
    {
        return File.ReadAllText(fileName);
    }
}
试验项目中的Pex方法:

[PexMethod]
public void CheckValidFileWithPex(string content)
{
    // arrange 
    var fileName = "test.txt";
    Moles_Example.Moles.MFileSystem.ReadAllTextString =
        delegate(string f)
        {
            Assert.IsTrue(f == fileName); return content;
        };
    // act 
    var test = new TestReader();
    test.LoadFile(fileName);
    // assert 
    Assert.AreEqual(content, test.Content);
}
当我第一次在
CheckValidFileWithPex(字符串内容)
上运行“Pex探索”时,生成了五种测试方法,其中
内容的值如下所示:

  • 空的
  • “”
  • “\0\0\0\0”
  • “测试”
  • “\0\0\0\0\0”
  • 但是,如果我再次运行“Pex探索”,在第二次执行之前,对生成的测试、现有测试项目代码或主项目没有任何更改,那么只有4个测试被列为已生成,并且缺少来自项3(“0\0\0\0”)的测试输入

    Pex生成的测试文件的源代码仍然有一个用于此案例的测试方法,但我不理解为什么Pex勘探结果中没有列出此案例


    感谢您的见解。

    我昨天和今天上午都多次重现了这一问题。。。但现在,每次运行Pex探索时,我都会得到所有5种测试方法的列表。虽然我没有做任何改变来改变这种行为,但一种解决方法是删除包含生成的测试方法的Pex生成的源文件,然后再次运行Pex探索。