【发布时间】:2012-08-21 11:46:12
【问题描述】:
当我尝试使用带有[Theory] 属性装饰的单元测试的批准时,它会说:
System.Exception: System.Exception : Approvals is not set up to use your test framework.
It currently supports [NUnit, MsTest, MbUnit, xUnit.net]
To add one use ApprovalTests.StackTraceParsers.StackTraceParser.AddParser() method to add implementation of ApprovalTests.StackTraceParsers.IStackTraceParser with support for your testing framework.
To learn how to implement one see http://blog.approvaltests.com/2012/01/creating-namers.html
at ApprovalTests.StackTraceParsers.StackTraceParser.Parse(StackTrace stackTrace)
at ApprovalTests.Namers.UnitTestFrameworkNamer..ctor()
at ApprovalTests.Approvals.GetDefaultNamer()
at ApprovalTests.Approvals.Verify(IApprovalWriter writer)
at ApprovalTests.Approvals.Verify(Object text)
似乎它只识别[Fact] 属性。我尝试关注link from stacktrace,但没有任何关于如何将您自己的命名器/解析器插入审批。
是否有任何入口点可以添加我自己的命名器/解析器?它本身似乎是微不足道的,唯一的问题是如何使用它:
public class TheoryNamer : AttributeStackTraceParser
{
protected override string GetAttributeType()
{
return typeof(TheoryAttribute).FullName;
}
public override string ForTestingFramework
{
get { return "xUnit Extensions"; }
}
}
【问题讨论】:
标签: c# unit-testing xunit.net approval-tests