【问题标题】:Pex does not accept testmethod as seedPex 不接受 testmethod 作为种子
【发布时间】:2014-12-09 18:47:28
【问题描述】:

我正在尝试在我的项目中使用 Pex 进行探索性测试。但是,我无法让它与我现有的测试作为测试种子一起运行。

我已成功使用 [PexArguments] 提供输入测试数据。 为了验证,我现在已经按照教程实现了 Capitalize 函数。 当我现在运行 Pex 时,将执行定义为注释的测试用例。 但是,不会执行方法中定义的测试。我按照here 的说明进行操作。

以防万一:我使用的是 VisualStudio 2010,Pex 说它是 0.94 版。

有人知道我做错了什么吗?

这是我的测试类:

[PexAllowedExceptionFromTypeUnderTest(typeof(InvalidOperationException))]
[PexAllowedExceptionFromTypeUnderTest(typeof(ArgumentException), AcceptExceptionSubtypes = true)]
public partial class Class1Test
{


    /// <summary>Test stub for Capitalize(String)</summary>
    [PexMethod]
    [PexArguments("foo")]
    public string Capitalize(string value)
    {
        string result = Class1.Capitalize(value);
        return result;
        // TODO: add assertions to method Class1Test.Capitalize(String)
    }

    [TestMethod]
    public void CapitalizeSeed()
    {
        string result = this.Capitalize("foo2");
        Assert.AreEqual("Foo", result);
    }
}

【问题讨论】:

    标签: c# visual-studio-2010 testing pex


    【解决方案1】:

    Pex 将从测试方法 CapitalizeSeed(...) 中获取值,并使用它来播种它的探索。但是,它不会执行该 TestMethod 本身。 当您从 Visual Studio 中运行 Pex 时,您应该看到在“值”列下报告的“foo2”作为输入之一。在返回语句之前的 PexMethod 中添加一个断言,如下所示: PexAssert.AreEqual("Foo", 结果); 你应该会看到失败的测试用例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-31
      • 2012-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-28
      • 1970-01-01
      • 2023-03-16
      相关资源
      最近更新 更多