Hi,
I'm trying to create a pipeline on Azure for test/coverage using JustMock, my application is Core 5.0*
After a long journey to make the build work, now I'm encountering an issue with the test (JustMockVSTestV2)
steps:
- task: vs-publisher-443.jm-vstest-2.JustMockVSTest-2.JustMockVSTest@2
displayName: 'VsTest - testAssemblies'
inputs:
testAssemblyVer2: |
**\bin\**\*test*.dll
!**\*TestAdapter.dll
!**\*TestPlatform*
!**\obj\**
!**\bin\**\ref\**
pathTo64BitJustMockProfiler: '[correctpath]\bin\Release\net5.0\runtimes\win-x64\native\Telerik.CodeWeaver.Profiler.dll'
pathTo32BitJustMockProfiler: '[correctpath]\bin\Release\net5.0\runtimes\win-x86\native\Telerik.CodeWeaver.Profiler.dll'
vsTestVersion: toolsInstaller
runTestsInIsolation: true
codeCoverageEnabled: true
otherConsoleOptions: '/Framework:.NETCoreApp,Version=v5.0.401 /Enablecodecoverage /logger:trx'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
My Test functions requires elevation:
Mock.SetupStatic(typeof(AStaticClass));
var response = Mock.Create<IRestResponse<string>>(); //this is restsharp
Mock.Arrange(() => response.Data)
.Returns("SomeData");
var client = Mock.Create<RestClient>(Constructor.Mocked);
Mock.Arrange(() => client.ExecuteAsync<string>(Arg.IsAny<IRestRequest>(), Arg.IsAny<CancellationToken>()))
.IgnoreInstance()
.TaskResult(response);
My test project works fine on my local machine when I enable JustMock profile, however I get a bunch of errors on Azure pipeline:
##[error][xUnit.net 00:00:03.76] ProjectTests.GetAsync_StateUnderTest_ExpectedBehavior [FAIL]
[xUnit.net 00:00:03.76] System.InvalidProgramException : Common Language Runtime detected an invalid program.
[xUnit.net 00:00:03.76] Stack Trace:
[xUnit.net 00:00:03.79] at ProjectTests.GetAsync_StateUnderTest_ExpectedBehavior()
[xUnit.net 00:00:03.79] at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
[xUnit.net 00:00:03.79] at ProjectTests.GetAsync_StateUnderTest_ExpectedBehavior()
ALSO
##[error]Testhost process exited with error: Cannot use file stream for [PATH\bin\Release\net5.0\testhost.deps.json]: No such file or directory
##[error]A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\hostedtoolcache\windows\dotnet'.
##[error]Failed to run as a self-contained app.
##[error] - The application was run as a self-contained app because 'PATH\bin\Release\net5.0\testhost.runtimeconfig.json' was not found.
##[error] - If this should be a framework-dependent app, add the 'PATH\bin\Release\net5.0\testhost.runtimeconfig.json' file and specify the appropriate framework.
##[error]. Please check the diagnostic logs for more information.
Please advice, I'm not able to make JustMock to work with Azure Pipeline.
Thanks