首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >NUnit有时会以"unable to locate fixture“结束。

NUnit有时会以"unable to locate fixture“结束。
EN

Stack Overflow用户
提问于 2014-12-01 18:06:08
回答 1查看 1.3K关注 0票数 8

NUnit-console 2.6.3有时会打印出以下错误消息,而不是运行测试。下面是我的Jenkins测试构建日志的摘录:

代码语言:javascript
复制
00:05:02.982 Process 'nunit-console-x86' [PID 3684] has begun profiling.
00:05:03.698 NUnit-Console version 2.6.3.13283
00:05:03.698 Copyright (C) 2002-2012 Charlie Poole.
00:05:03.698 Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
00:05:03.698 Copyright (C) 2000-2002 Philip Craig.
00:05:03.698 All Rights Reserved.
00:05:03.698 
00:05:03.698 Runtime Environment - 
00:05:03.701    OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
00:05:03.701   CLR Version: 2.0.50727.5485 ( Net 3.5 )
00:05:03.701 
00:05:03.795 ProcessModel: Default    DomainUsage: Single
00:05:03.795 Execution Runtime: net-3.5
00:05:33.886 Unable to locate fixture 
00:05:33.895 Process 'nunit-console-x86' [PID 3684] has finished profiling.

它是随机发生的。我不会更改测试程序集或NUnit配置。我通过NCover运行NUnit,但是当我从命令行单独使用NUnit时,同样的问题重复出现。

在NUnit中启用详细日志记录后,我注意到nunit-agent进程在nunit-console运行半分钟后将其第一条消息打印到日志中。我从源代码中发现,nunit-console会等待30秒,以等待衍生的nunit-agent进程注册自己。显然,有些东西延迟加载nunit-agent,因此超时在nunit-console中被击中,导致“无法定位装置”。在此之后,nunit-agent进程仍在运行,我必须手动终止它。

NUnit-控制台日志:

代码语言:javascript
复制
InternalTrace: Initializing at level Verbose
09:14:08.992 Info  [ 1] Runner: NUnit-console.exe starting
09:14:09.006 Debug [ 1] ServiceManager: Added SettingsService
09:14:09.006 Debug [ 1] ServiceManager: Added DomainManager
09:14:09.007 Debug [ 1] ServiceManager: Added ProjectService
09:14:09.007 Debug [ 1] ServiceManager: Added AddinRegistry
09:14:09.007 Debug [ 1] ServiceManager: Added AddinManager
09:14:09.007 Debug [ 1] ServiceManager: Added TestAgency
09:14:09.008 Info  [ 1] ServiceManager: Initializing SettingsService
09:14:09.008 Info  [ 1] ServiceManager: Initializing DomainManager
09:14:09.008 Info  [ 1] ServiceManager: Initializing ProjectService
09:14:09.008 Info  [ 1] ServiceManager: Initializing AddinRegistry
09:14:09.008 Info  [ 1] ServiceManager: Initializing AddinManager
09:14:09.009 Debug [ 1] ServiceManager: Request for service IAddinRegistry satisfied by AddinRegistry
09:14:09.017 Info  [ 1] ServiceManager: Initializing TestAgency
09:14:09.041 Debug [ 1] ServiceManager: Request for service ProjectService satisfied by ProjectService
09:14:09.054 Debug [ 1] RuntimeFrameworkSelector: Current framework is net-3.5
09:14:09.054 Debug [ 1] RuntimeFrameworkSelector: No specific framework requested
09:14:09.054 Debug [ 1] ServiceManager: Request for service ISettings satisfied by SettingsService
09:14:09.058 Debug [ 1] RuntimeFrameworkSelector: Assembly D:\Jenkins\jobs\Job1\GreyBoxTests\bin\Debug\GreyBoxTests.dll uses version 4.0.30319
09:14:09.064 Debug [ 1] ServiceManager: Request for service TestAgency satisfied by TestAgency
09:14:09.065 Debug [ 1] RuntimeFrameworkSelector: Test will use net-4.0 framework
09:14:09.066 Info  [ 1] ProcessRunner: Loading GreyBoxTests.dll
09:14:09.067 Info  [ 1] TestAgency: Getting agent for use under net-4.0
09:14:09.070 Debug [ 1] TestAgency: Using nunit-agent at c:\Program Files (x86)\NUnit 2.6.3\bin\nunit-agent-x86.exe
09:14:09.091 Info  [ 1] TestAgency: Launched Agent process 7240 - see nunit-agent_7240.log
09:14:09.091 Info  [ 1] TestAgency: Command line: "c:\Program Files (x86)\NUnit 2.6.3\bin\nunit-agent-x86.exe" 65bc321d-e7dc-4a98-81e6-919b87d5c783 tcp://127.0.0.1:56614/TestAgency
09:14:09.091 Debug [ 1] TestAgency: Waiting for agent {65bc321d-e7dc-4a98-81e6-919b87d5c783} to register
09:14:39.091 Info  [ 1] Runner: NUnit-console.exe terminating

NUnit-代理日志:

代码语言:javascript
复制
InternalTrace: Initializing at level Verbose
09:14:41.859 Info  [ 1] NUnitTestAgent: Agent process 7240 starting
09:14:41.876 Info  [ 1] NUnitTestAgent: Running under version 4.0.30319.18444, Net 4.5
09:14:41.876 Info  [ 1] NUnitTestAgent: Adding Services
09:14:41.876 Debug [ 1] ServiceManager: Added SettingsService
09:14:41.877 Debug [ 1] ServiceManager: Added ProjectService
09:14:41.877 Debug [ 1] ServiceManager: Added DomainManager
09:14:41.877 Debug [ 1] ServiceManager: Added AddinRegistry
09:14:41.877 Debug [ 1] ServiceManager: Added AddinManager
09:14:41.877 Info  [ 1] NUnitTestAgent: Initializing Services
09:14:41.878 Info  [ 1] ServiceManager: Initializing SettingsService
09:14:41.878 Info  [ 1] ServiceManager: Initializing ProjectService
09:14:41.878 Info  [ 1] ServiceManager: Initializing DomainManager
09:14:41.878 Info  [ 1] ServiceManager: Initializing AddinRegistry
09:14:41.878 Info  [ 1] ServiceManager: Initializing AddinManager
09:14:41.879 Debug [ 1] ServiceManager: Request for service IAddinRegistry satisfied by AddinRegistry
09:14:41.906 Info  [ 1] NUnitTestAgent: Connecting to TestAgency at tcp://127.0.0.1:56614/TestAgency
09:14:41.907 Info  [ 1] NUnitTestAgent: Starting RemoteTestAgent
09:14:41.908 Info  [ 1] RemoteTestAgent: Agent starting

有没有NUnit专家可以帮我?

EN

回答 1

Stack Overflow用户

发布于 2018-09-07 07:43:58

可能的解决方法,由Charlie在that Google Groups thread中建议

避免这种情况的一种方法是停止使用代理。更改配置文件(nunit-console-x86.exe.config)以在2.0 CLR之前使用4.0 CLR。然后,测试将在相同的进程中运行,并且不会创建代理。

我已经确认,在nunit-console.exe.config文件(或nunit-console-x86.exe.config)的<startup>中添加<supportedRuntime version="v4.0.30319" />并删除<supportedRuntime version="v2.0.50727" (如果存在)确实会导致我的测试运行,而不会产生nunit-agent.exe进程。我还没有确认这是否修复了我的情况下的错误"unable to locate fixture“,但OP (krzysiek_w)确实在同一个线程中确认了它:

我没有意识到在没有nunit-agent的情况下在nunit-console中运行测试的可能性。在nunit-console配置文件中设置受支持的框架后,测试将在不创建独立进程的情况下执行,从而完全修复问题。

作为补充,可以将选项/trace=Verbose传递给NUnit以获取更多信息,就像krzysiek_w在该线程中所做的那样。对我来说,这些日志输出到C:\Users\(myuser)\AppData\Local\NUnit\logs

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27225962

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档