ASP.NET 5添加MVC6单元测试项目(ASP.NET 5 Adding MVC6 Unit Test Project)

编程入门 行业动态 更新时间:2024-10-28 20:20:36
ASP.NET 5添加MVC6单元测试项目(ASP.NET 5 Adding MVC6 Unit Test Project)

我正在尝试将单元测试项目添加到ASP.NET 5解决方案中。

我添加了ASP.NET 5类库项目,并在我的project.json中引用了所需的包,如下所示: -

{ "dependencies": { "xunit.runners": "1.0.0-alpha3", "Moq": "4.2.1502.911", "xunit": "2.0.0-rc4-build2924" }, "commands": { "test": "Xunit.KRunner" }, "frameworks": { "net451": { "dependencies": { } } } }

当我尝试在类文件中引用一个Xunit的attrivute时,如下所示: -

使用Xunit;

namespace LondonUnderground.UnitTests { public class RoutesTests { [Fact] public void TestShizz() { } } }

我收到一个错误,告诉我我需要System.Runtime版本4.0.0.0才能访问“Attribute”类。

如果我尝试在project.json文件中添加对此的引用,它将安装System.Runtime 4.0.20.0 Beta。

有什么建议么?

I'm trying to add Unit Test Project to a ASP.NET 5 Solution.

I've added ASP.NET 5 class library project and referenced the required packaes in my project.json as below :-

{ "dependencies": { "xunit.runners": "1.0.0-alpha3", "Moq": "4.2.1502.911", "xunit": "2.0.0-rc4-build2924" }, "commands": { "test": "Xunit.KRunner" }, "frameworks": { "net451": { "dependencies": { } } } }

When I try to reference a to an attrivute of Xunit in a class file as follows :-

using Xunit;

namespace LondonUnderground.UnitTests { public class RoutesTests { [Fact] public void TestShizz() { } } }

I'm getting an error, telling me that i need the System.Runtime version 4.0.0.0 in order to access "Attribute" class.

If i try adding a reference to this in the project.json file, it installs System.Runtime 4.0.20.0 Beta.

Any suggestions?

最满意答案

这是我的project.json,它可以用于测试。

{ "version": "1.0.0-*", "dependencies": { "xunit": "2.1.0-beta1-*", "xunit.runner.aspnet": "2.1.0-beta1-*" }, "frameworks": { "aspnet50": { "dependencies": { } }, "aspnetcore50": { "dependencies": { "System.Runtime": "4.0.20-beta-22523" } } }, "commands": { "test": "xunit.runner.aspnet" } }

this is my project.json that works with tests.

{ "version": "1.0.0-*", "dependencies": { "xunit": "2.1.0-beta1-*", "xunit.runner.aspnet": "2.1.0-beta1-*" }, "frameworks": { "aspnet50": { "dependencies": { } }, "aspnetcore50": { "dependencies": { "System.Runtime": "4.0.20-beta-22523" } } }, "commands": { "test": "xunit.runner.aspnet" } }

更多推荐

本文发布于:2023-07-29 20:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319627.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元测试   项目   NET   ASP   Unit

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!