Approval-Test抛出System.MissingMethodException

Las*_*tio 5 .net c# unit-testing approval-tests

我正在尝试使用Approval-Tests但是甚至无法运行"Hello World".当我运行测试时,我得到了

Test Name:  TestHelloWorld
Test FullName:  HelloApprovalTests.Class1.TestHelloWorld
Test Source:    C:\Users\Lassi\Documents\Visual Studio 2015\Projects\HelloApprovalTests\HelloApprovalTests\Class1.cs : line 14
Test Outcome:   Failed
Test Duration:  0:00:00.01

Result StackTrace:  
at ApprovalTests.Namers.UnitTestFrameworkNamer..ctor()
   at ApprovalTests.Approvals.<.cctor>b__c()
   at ApprovalTests.Approvals.GetDefaultNamer()
   at ApprovalTests.Approvals.Verify(IApprovalWriter writer)
   at ApprovalTests.Approvals.Verify(String text)
   at HelloApprovalTests.Class1.TestHelloWorld() in C:\Users\Lassi\Documents\Visual Studio 2015\Projects\HelloApprovalTests\HelloApprovalTests\Class1.cs:line 15
Result Message: System.MissingMethodException : Method not found: 'System.Diagnostics.StackTrace ApprovalUtilities.CallStack.Caller.get_StackTrace()'.
Run Code Online (Sandbox Code Playgroud)

我的班级是:

using ApprovalTests;
using ApprovalTests.Reporters;
using NUnit.Framework;

namespace HelloApprovalTests
{
    [TestFixture]
    [UseReporter(typeof(DiffReporter))]
    public class Class1
    {
        [Test]
        public void TestHelloWorld()
        {
            Approvals.Verify("Hello World Welcome to ApprovalTests");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能运行并创建一个文件?

lle*_*lco 6

Nuget安装上有些奇怪.如果您更新ApprovalUtilities它将起作用.

  • 这是因为NuGet的默认依赖行为,即安装最低版本的依赖包.看起来像ApprovalTests 3.0.11至少需要ApprovalUtilities 3.0.11才能工作,它应该可以添加到它的清单中. (2认同)