代码之家  ›  专栏  ›  技术社区  ›  Michael Shimmins

强制MonoDevelop在特定运行时下“运行测试”

  •  4
  • Michael Shimmins  · 技术社区  · 14 年前

    在OS X上的Mono下,有一堆单元测试失败,错误如下:

    System.TypeLoadException : Could not load type 'System.Func``2' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

    关于所讨论的单元测试:

    [Test]
    public void CanAuthenticateValidUser()
    {
        const string testUsername = "jappleseed";
    
        var repo = new Mock<IUserRepository>();
        repo.Setup(x => x.GetByUsername(testUsername)).Returns(GetTestUser());
    
        var authenticator = new Authenticator(repo.Object);
        var result = authenticator.Authenticate(testUsername, "test");
    
        Assert.That(result, Is.True);
    }
    

    运行Mono2.8,运行MonoDevelop2.4。

    有人有什么建议可以避开这件事吗?

    编辑:

    应该指出这个错误来自MonoDevelop中“Unit Tests”pad中的内置“runtests”命令。

    编辑2:

    在控制台中运行根据jpobst建议强制运行时。我想问题已经变成了如何让MonoDevelop在特定的框架下展示运行测试了?

    shimms:Debug shimms$ mono ~/Development/nunit/bin/net-2.0/nunit-console.exe Convergence.Core.Services.Tests.dll

    不过,引发了相同的异常:

    shimms:Debug shimms$ mono --runtime=v4.0.30319 ~/Development/nunit/bin/net-2.0/nunit-console.exe Convergence.Core.Services.Tests.dll

    所有测试均通过

    1 回复  |  直到 14 年前
        1
  •  6
  •   jpobst    14 年前

    没有一个名为“mscorlib”的程序集,它是“mscorlib”。是打字错误吗?还是一个断章取义的参考?


    第二次尝试:

    您确定您的测试是根据4.0(DMC)编译的吗?

    您还可以尝试使用以下命令覆盖运行时:

    mono—运行时=v4.0.30319 mytests.exe