MSTest异常:单元测试适配器引发异常:成员的类型无法解析 [英] MSTest exception: Unit Test Adapter threw exception: Type is not resolved for member

查看:86
本文介绍了MSTest异常:单元测试适配器引发异常:成员的类型无法解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我使用Microsoft的单元测试框架编写测试.当我从Visual Studio运行它们时,我所有的测试都通过了,但是当我从MSBuild运行测试时,所有测试都失败,并显示以下erorr消息:

In my project I write tests using Microsoft's unit testing framework. All of my tests pass when I run them from Visual Studio but when I run the tests from MSBuild all of the tests fail with the following erorr message:

单元测试适配器引发异常: 会员的类型无法解析 SomeType SomeAssembly Version = assemblyVersion , Culture = neutral,PublicKeyToken = ..

Unit Test Adapter threw exception: Type is not resolved for member SomeType,SomeAssembly Version=assemblyVersion, Culture=neutral, PublicKeyToken=..

找不到的程序集是所有项目引用的第三方程序.

The assembly not found is a 3rd party assembly referenced by all of the projects.

TFS使用了构建脚本,因此我添加了以下几行:

The build script is used by TFS so I've aded the following lines:

<RunTest>true</RunTest>

<ItemGroup>
    <MetaDataFile Include="$(BuildProjectFolderPath)myproject.vsmdi">
        <TestList>CI_Tests</TestList>
    </MetaDataFile>
</ItemGroup>

我找到了此帖子显示了该问题的解决方案,但不幸的是,我无法更改TFS服务器上的文件.

I've found the this post that shows a solution to this issue but unfortunatly I cannot chnage the files on the TFS server.

帮助!

推荐答案

首先要检查的是将这个程序集复制到msbuild运行测试的文件夹中.出于某些历史原因,可能在bin/Debug文件夹中有一个副本,但是在项目中的依赖关系未正确设置.

The first thing to check would be if this assembly is copied to the folder from which msbuild runs the tests. It might be the case that you have a copy in your bin/Debug folder because of some historic reasons, but the dependency is not set up properly in the project.

这篇关于MSTest异常:单元测试适配器引发异常:成员的类型无法解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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