控制台应用程序内的 MSTest
我试图在控制台应用程序中运行一些测试
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting; // this doesn't work
我得到的错误是:
命名空间“Microsoft”中不存在类型或命名空间名称“VisualStudio”(您是否缺少程序集引用?)
但这一切都有效在一个单独的测试项目中:
问题: 有什么不同?
I was trying to get some tests running inside a console application
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting; // this doesn't work
The error I'm getting is:
The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Yet it all works in a seperate test project:
Question: What is different?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将 ConsoleApplication 的目标框架更改为
.Net Framework 4
(NOT.NET Framework 4 Client Profile
)您无法引用
Microsoft.VisualStudio.QualityTools.UnitTestFramewor
,因为它不是客户端配置文件框架的一部分。编辑:抱歉,您已经有了...
您需要在控制台应用程序中引用
Microsoft.VisualStudio.QualityTools.UnitTestFramework
。您可以从
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies
添加它 默认的 Visual Studio Test 项目默认具有此引用...
You need to change the target framework of the ConsoleApplication to be
.Net Framework 4
(NOT.NET Framework 4 Client Profile
)You can't reference
Microsoft.VisualStudio.QualityTools.UnitTestFramewor
, because it is not part of the client profile framework.EDIT: Sorry, you have that already ...
You need the reference to
Microsoft.VisualStudio.QualityTools.UnitTestFramework
in your console application.You can add it from
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies
The default Visual Studio Test project has this reference by default...
您可以从 Visual Studio 创建测试项目,并将项目输出类型从类库更改为控制台应用程序。
问候
阿西姆·班萨尔
You can create test project from visual studio and change the project output type from class library to console application.
Regards
Aseem Bansal