无法使用的xUnit在ASP.NET VNext单元测试和Visual Studio 2015年RC [英] Not able to use XUnit for unit tests in ASP.NET VNext and Visual Studio 2015 RC

查看:518
本文介绍了无法使用的xUnit在ASP.NET VNext单元测试和Visual Studio 2015年RC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Visual Studio 2015年RC的解决方案如下:

I created a a Visual Studio 2015 RC solution as follows:

Project
  global.json
Source
  MvcProject
  MvcProject.Test

MvcProject.Test是我创建了一个测试类库。

MvcProject.Test is a class library where I created a Test.

该global.json文件有以下几点:

The global.json file has the following:

{
  "projects": [ "Source" ],
  "sdk": {
    "version": "1.0.0-beta4"
  }
}    

和project.json在MvcProject.Test是:

And project.json in MvcProject.Test is:

{
  "compilationOptions": {
    "warningsAsErrors": true
  },
  "dependencies": {
    "Microsoft.AspNet.Mvc": "6.0.0-*",
    "xunit.runner.aspnet": "2.0.0-aspnet-*"
  },
  "commands": {
    "test": "xunit.runner.aspnet"
  },
  "frameworks": {
    "dnx451": {
      "dependencies": {
        "Moq": "4.2.1506.2016"
      }
    }
  }
}

然后,我创建了一个简单的测试:

I then created a simple test:

using Xunit;

namespace MvcProject.Test {
  public class FirstTests {

    [Fact]
    public void HelloTest() {
      Assert.Equal(2, 2);
    }

  }
}

当我建立孤子我得到的错误:

When I build the solition I get the error:

The type or namespace name 'Fact' could not be found (are you missing a using directive or an assembly reference?)  MvcProject.Test.DNX 4.5.1   

The name 'Assert' does not exist in the current context Bityond.Test.DNX 4.5.1  

我是什么在我的配置丢失?

What am I missing in my configuration?

推荐答案

这<一个href=\"http://blogs.msdn.com/b/webdev/archive/2015/08/06/unit-testing-with-dnx-asp-net-5-projects.aspx\"相对=nofollow>博客文章与RTM的作品。请在博客上发表评论,如果您有任何问题。

This blog post works with RTM. Please leave comments on the blog if you have any problems.

这篇关于无法使用的xUnit在ASP.NET VNext单元测试和Visual Studio 2015年RC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆