MSTest异常:单元测试适配器引发异常:成员的类型无法解析

编程入门 行业动态 更新时间:2024-10-24 18:27:37
本文介绍了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异常:单元测试适配器引发异常:成员的类型无法解析

本文发布于:2023-10-31 05:03:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545083.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:异常   适配器   单元测试   成员   类型

发布评论

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

>www.elefans.com

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