我试图通过构建管道中的变量组使用来自 KeyVault 的机密来覆盖我的集成测试中的一些变量。
我添加了一个 .runsettings 文件,并且在通过测试进行调试时能够检索虚拟变量。但是,一旦执行了读取虚拟值的指令,测试就会突然退出,并出现以下错误:
Value of CrmClientSecret is JustSomeSecret
Step into: Stepping over non-user code
'IntegrationTests.Helpers.Helper.DeleteUserFromCRM' Step into: Stepping over
non-user code 'IntegrationTests.Helpers.Helper. d__4..ctor' 'testhost.exe'
(CLR v4.0.30319: TestSourceHost: Enumering source
(C:\source\repos\Azure\Integrat ionTests\bin\Debug\Tests.dll)): Loaded
'C:\source\repos\Azure\IntegrationTests\bin\Debug\Utilities.dll'. Symbols
loaded. The thread 0x527c has exited with code 0 (0x0). The program '[26720]
testhost.exe' has exited with code -1 (0xffffffff). The program '[26720]
testhost.exe: Program Trace' has exited with code 0 (0x0).
Any help is appreciated
该解决方案托管在 Visual Studio Ent 2017 中。测试项目为 net 4.61,并安装了以下 Nuget 包:
- Microsoft.NET.Test.Sdk v 15.9.0
- MSTest.TestAdapter v 1.3.2
- MSTest.TestFramework v 1.3.2
- NUnit3TestAdapter 版本 3.11.0
这是我的测试结果:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<MaxCpuCount>2</MaxCpuCount>
<ResultsDirectory>.\TestResults</ResultsDirectory>
<TargetPlatform>x64</TargetPlatform>
<TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
<TestAdaptersPaths>%systemdrive%\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Extensions</TestAdaptersPaths>
<TestSessionTimeout>10000</TestSessionTimeout>
</RunConfiguration>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
</Exclude>
</ModulePaths>
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>
</CodeCoverage>
</Configuration>
</DataCollector>
<DataCollector uri="datacollector://microsoft/VideoRecorder/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder.VideoRecorderDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Screen and Voice Recorder">
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<TestRunParameters>
<Parameter name="AmbassadorsDbConnectionString"
value="TheConnectionString" />
<Parameter name="CRMClientSecret" value="JustSomeSecret" />
<Parameter name="webAppPassword" value="Password" />
</TestRunParameters>
<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False
<DeploymentEnabled>False</DeploymentEnabled>
<AssemblyResolution>
<Directory path="D:\myfolder\bin\" includeSubDirectories="false"/>
</AssemblyResolution>
</MSTest>
</RunSettings>