第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

NUnit Console Runner 在使用 Kentico Fakes 時未找到所有單元測試

NUnit Console Runner 在使用 Kentico Fakes 時未找到所有單元測試

C#
躍然一笑 2022-07-23 16:45:59
我有 3 個 NUnit 測試程序集正在測試我為 Kentico CMS 平臺編寫的自定義代碼。我可以在 Visual Studio(使用 NUnit 適配器)和 NUnit 控制臺運行程序中運行這些測試。我現(xiàn)在正試圖讓這些測試在我的 TeamCity 構(gòu)建服務(wù)器上運行。我已經(jīng)設(shè)置了 NUnit 運行程序,它正在返回一些結(jié)果,但我發(fā)現(xiàn)并非所有測試都在執(zhí)行。在一種情況下,我的一個程序集報告沒有測試裝置,盡管我知道肯定有。系統(tǒng)詳情TeamCity v10.0.5(內(nèi)部版本 42677)現(xiàn)在 3.8.1Nunit.ConsoleRunner 3.8.0肯蒂科 11Kentico.Libraries - 11.0.35Kentico.Libraries.Tests - 11.0.35問題 我有一個名為gto.ecommerce.core.tests.dll. 當(dāng)它在 TeamCity 服務(wù)器上運行時,我得到這個輸出(直接來自 NUnit 控制臺運行器):NUnit Console Runner 3.8.0Copyright (c) 2018 Charlie Poole, Rob ProuseRuntime Environment   OS Version: Microsoft Windows NT 6.3.9600.0  CLR Version: 4.0.30319.42000Test Files    D:\TeamCity\buildAgent\work\4a231fb0e41e27f5\Tests\gto.ecommerce.core.tests\bin\Build\gto.ecommerce.core.tests.dllRun Settings    DisposeRunners: True    WorkDirectory: D:\TeamCity\buildAgent\work\4a231fb0e41e27f5\packages\NUnit.ConsoleRunner.3.8.0\tools    ImageRuntimeVersion: 4.0.30319    ImageTargetFrameworkName: .NETFramework,Version=v4.6    ImageRequiresX86: False    ImageRequiresDefaultAppDomainAssemblyResolver: False    NumberOfTestWorkers: 8Test Run Summary  Overall result: Passed  Test Count: 6, Passed: 6, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0  Start time: 2019-01-15 10:16:53Z    End time: 2019-01-15 10:16:54Z    Duration: 1.219 secondsResults (nunit3) saved as TestResult.xml這些與運行 TeamCity 構(gòu)建步驟時返回的結(jié)果完全相同。但是,這里應(yīng)該有更多的測試。如果我將 TeamCity 構(gòu)建的二進(jìn)制文件復(fù)制到本地計算機(jī)并運行相同的 NUnit 控制臺運行程序命令,我會得到以下結(jié)果:NUnit Console Runner 3.8.0 Copyright (c) 2018 Charlie Poole, Rob ProuseRuntime Environment   OS Version: Microsoft Windows NT 10.0.14393.0  CLR Version: 4.0.30319.42000Test Files    C:\temp\gto-gtoengineering\TeamCity\gto.ecommerce.core.tests\Build\gto.ecommerce.core.tests.dllRun Settings    DisposeRunners: True    WorkDirectory: Z:\    ImageRuntimeVersion: 4.0.30319    ImageTargetFrameworkName: .NETFramework,Version=v4.6    ImageRequiresX86: False    ImageRequiresDefaultAppDomainAssemblyResolver: False    NumberOfTestWorkers: 8請注意我的機(jī)器如何說總共有 33 個測試,這是正確的數(shù)字。
查看完整描述

1 回答

?
繁星淼淼

TA貢獻(xiàn)1775條經(jīng)驗 獲得超11個贊

經(jīng)過大量跟蹤后,我發(fā)現(xiàn)原因不是 NUnit 或 TeamCity,而是因為我使用了Kentico的庫,特別是我使用 Kentico 的CMS.Tests庫來幫助對我的自定義 Kentico 代碼進(jìn)行單元測試,如此處所述。


因此,我更新了我的問題以更具體地針對 Kentico,并將在下面提供解決此問題的解決方案。


確定根本原因

經(jīng)過一番互聯(lián)網(wǎng)搜索后,我發(fā)現(xiàn) NUnit 控制臺運行器有一個--trace 命令行選項。通過傳入,--trace=Verbose我能夠?qū)⒏櫸募懭霝榭刂婆_運行程序設(shè)置的工作目錄,然后比較兩臺機(jī)器。我的本地開發(fā)機(jī)器顯示所有裝置都已正確找到,但 TeamCity 服務(wù)器會生成跟蹤文件,其輸出類似于:


InternalTrace: Initializing at level Debug

14:41:48.559 Debug [ 5] DefaultTestAssemblyBuilder: Loading D:\TeamCity\buildAgent\work\4a231fb0e41e27f5\Tests\rwy.common.core.tests\bin\Build\rwy.common.core.tests.dll in AppDomain domain-

14:41:48.570 Debug [ 5] DefaultTestAssemblyBuilder: Examining assembly for test fixtures

14:41:48.579 Debug [ 5] DefaultTestAssemblyBuilder: Found 12 classes to examine

14:41:48.691 Error [ 5] DefaultTestAssemblyBuilder: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

File name: 'Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)

   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)

   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)

   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)

   at System.Reflection.CustomAttribute.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Int32 attributeCtorToken, Boolean mustBeInheritable)

   at System.Reflection.CustomAttribute.IsDefined(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)

   at NUnit.Framework.Internal.Reflect.GetMethodsWithAttribute(Type fixtureType, Type attributeType, Boolean inherit)

   at NUnit.Framework.Internal.TestFixture..ctor(ITypeInfo fixtureType, Object[] arguments)

   at NUnit.Framework.Internal.Builders.DefaultSuiteBuilder.BuildFrom(ITypeInfo typeInfo)

   at NUnit.Framework.Api.DefaultTestAssemblyBuilder.GetFixtures(Assembly assembly, IList names)


WRN: Assembly binding logging is turned OFF.

To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.

Note: There is some performance penalty associated with assembly bind failure logging.

To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

我不明白的部分是參考,Microsoft.VisualStudio.QualityTools.UnitTestFramework因為這與 NUnit 無關(guān) - 那是 MSTest 庫,我的項目中根本沒有 MSTest 單元測試。


那時我意識到這是一個 Kentico 問題——因為CMS.Tests.dll被引用來幫助編寫虛假 Info 對象和提供程序的 Kentico適用于 NUnit和MSTest。


在我的開發(fā)機(jī)器Microsoft.VisualStudio.QualityTools.UnitTestFramework上安裝了 Visual Studio,正如這個問題中所解釋的那樣,這意味著每次我運行測試時都沒有問題 - 可以在我的系統(tǒng)上找到依賴的 DLL。但是,除非明確安裝,否則這在構(gòu)建服務(wù)器上永遠(yuǎn)不可用。

解決方案

為了解決這個問題,我遵循了這個建議

  1. 復(fù)制Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll到我的解決方案中并將其提交給我的倉庫。

  2. 在我的所有測試項目中包含對這個程序集的引用,確保Copy Local是真的。

通過簡單地引用這個 DLL,構(gòu)建會將它與所有其他依賴項一起復(fù)制到bin文件夾中,然后可以在它不是全局可用的環(huán)境中使用。


查看完整回答
反對 回復(fù) 2022-07-23
  • 1 回答
  • 0 關(guān)注
  • 123 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號