如何为“测试程序集文件规范”指定正确的搜索掩码TFS2010 构建定义中的对话框?
我不知道如何指定正确的掩码来在 TFS2010 构建定义中搜索我的测试程序集。 我没有使用默认的二进制文件夹来存储输出程序集。每个测试项目都有自己的 bin\Debug 或 bin\Release 输出文件夹。 如果我使用默认掩码 **\*test*.dll 我的测试失败并出现此错误:
API restriction: The assembly 'file:///E:\Builds\....\obj\Debug\xxx.IntegrationTests.dll'
has already loaded from a different location. It cannot be loaded from a new location within the same appdomain.
这是因为 **\*test*.dll 掩码将在 bin\Debug 和 obj\Debug 中找到同一程序集的多个结果文件夹。
我尝试更改此掩码以排除 obj\Debug 文件夹并仅使用 bin:
**\bin\Debug\*test*.dll
**\bin\**\*test*.dll
**\Debug\*test*.dll
但 FindMatchingFiles 活动始终返回 0 结果。
仅当我传递测试程序集的完整路径时它才起作用。
如果我想从测试程序集搜索中排除 obj\Debug 文件夹,正确的掩码是什么?
解决方法:
我仍在使用 FindMatchingFiles 活动,但我必须使用以下参数添加分配活动:
To - testAssemblies
From - testAssemblies.Where(Function(o) Not o.Contains("\obj\")).ToList()
我正在以这种方式过滤“obj”文件夹中找到的所有测试程序集。
I don't know how to specify correct mask to search for my test assemblies in TFS2010 build definition.
I'm not using default Binaries folder for output assemblies. Each test project has its own bin\Debug or bin\Release output folder.
If I use the default mask **\*test*.dll my tests failed with this error:
API restriction: The assembly 'file:///E:\Builds\....\obj\Debug\xxx.IntegrationTests.dll'
has already loaded from a different location. It cannot be loaded from a new location within the same appdomain.
This is because **\*test*.dll mask will find multiple results for the same assembly in the bin\Debug and obj\Debug folders.
I tried to change this mask to exclude obj\Debug folder and use bin only:
**\bin\Debug\*test*.dll
**\bin\**\*test*.dll
**\Debug\*test*.dll
but FindMatchingFiles activity return always 0 results.
It is working only when I pass full path to the test assembly.
What is the correct mask if I want to exclude obj\Debug folders from test assembly search?
WORKAROUND:
I'm still using FindMatchingFiles activity, but I had to add Assign activity with following params:
To - testAssemblies
From - testAssemblies.Where(Function(o) Not o.Contains("\obj\")).ToList()
I'm filtering all test assemblies found in the "obj" folders this way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您感兴趣的构建活动名为“查找测试程序集”:
因此,您在构建定义中放置的内容将连接在构建脚本变量
outputDirectory
。此
outputDirectory
会针对活动“Initialize OutputDirectory”中的每个配置进行初始化:您可以对新构建进行排队,将“日志详细程度”设置为等于
诊断.一旦运行(并失败),请检查您的构建发生了什么。
我的猜测是您的配置/平台设置有问题,但没有具体的输入,这只是猜测。
The build activity that is of interest to you is named "Find Test Assemblies":
So, what you place at the build definition is concatenated after build script variable
outputDirectory
.This
outputDirectory
is initialized for each configuration in activity "Initialize OutputDirectory":You can queue a new build where you set your 'Logging Verbosity' equal to
Diagnostic
. Once this has ran (and failed), check for what is going on with your build.My guess is that you have issues with your configuration/platform settings, but without concrete input that's just guessing.
我遇到了与你基本相同的问题。我有开发人员使用辅助测试程序集 (TestHelper) 和导致此问题的 _PublishedWebsites 文件夹。
我最终解决这个问题的方法是解决将多个相同的测试 DLL 传递给 MSTest 的问题。 “好吧,这就是我想要用我的面具做的事情,”你可能会想!我尝试了相同的解决方案,但结果是空的。
我编写了一个自定义任务,并在构建过程找到测试程序集后将其插入。以下是自定义任务的代码:
您可以将其插入到“查找测试程序集”任务之后。
I ran into basically the same issue that you have. I have developers using a helper test assembly (TestHelper) and a _PublishedWebsites folder that was causing this issue.
What I ended up doing to fix this was solve the problem of getting multiple of the same test DLL passed to MSTest. "Well, that's what I'm trying to do with my mask," you may think! I tried that same solution but came up empty.
I wrote a custom task and inserted it after the build process finds the test assemblies. Here's the code for the custom task:
You'd insert this after the "Find Test Assemblies" task.
我仍在使用 FindMatchingFiles 活动,但我必须添加具有以下参数的分配活动:
To - testAssemblies
来自 - testAssemblies.Where(Function(o) Not o.Contains("\obj\")).ToList()
我正在以这种方式过滤“obj”文件夹中找到的所有测试程序集。
I'm still using FindMatchingFiles activity, but I had to add Assign activity with following params:
To - testAssemblies
From - testAssemblies.Where(Function(o) Not o.Contains("\obj\")).ToList()
I'm filtering all test assemblies found in the "obj" folders this way.
过滤器开头的
**
可能是问题所在。搜索的起点位于您意想不到的位置,并且子目录不包含您的测试文件。要解决此问题,请将
..\..\..
添加到过滤器表达式的开头。出于调试目的,这将脱离您所在的子目录结构,并在系统上对测试文件执行更广泛的搜索。您还可以将第一部分设置为绝对,以确保您在正确的目录子树中搜索。作为替代方案,您还可以在构建系统上运行 processmonitor 会话,以查看您的 TFS 构建引擎实际上正在寻找您的测试程序集。或者在构建工作流程/活动本身中执行一些日志记录。
发现问题后,再次缩小搜索范围,不要搜索不相关的子目录结构。
Probably the
**
at the beginning of your filter is the problem. The starting point of the search is at a location you would not expect it to be and subdirectories do not contain your test files.To troubleshoot this problem, please add
..\..\..
to the start of your filter expression. For debugging purposes, this will get out of the subdirectory structure you're in and perform a wider search on your system for the test files. You can also make the first part absolute, to make sure you're searching in the right directory subtrees.As alternative, you can also run a processmonitor session on your build system, to see where your TFS build engine is actually looking for your test assemblies. Or perform some logging in the build workflow / activity itself.
When you have found the problem, narrow your search window again to not search irrelevant subdirectory structures.
我遇到了这个问题,但发现不仅仅是 bin 和 obj 包含重复项,我还有许多相同 DLL 的副本出现在各个项目文件夹中。
Ludwo 的
Assign
答案几乎足以解决这个问题,但对于我的情况,我需要为From
参数提供一个更通用的值。该 VB 按文件名对发现的文件路径进行分组,然后从每个组中选取第一个路径。当然,只有当且仅当每个文件名映射到一个逻辑 DLL 时,它才有效:I ran into this issue but found that rather than just bin and obj containing duplicates, I had many copies of the same DLLs appearing in various project folders.
Ludwo's answer with
Assign
was nearly enough to fix it, but for my situation I needed a more general value for theFrom
parameter. This VB groups the discovered file paths by file name, and then picks the first path from each group. It of course will only work if and only if each file name maps to one logical DLL: