0
votes

I have a .NET Core 2.2 Unit Test Setup in an Azure Dev Ops build pipeline, these are xunit tests

steps:
- task: DotNetCoreCLI@2
  displayName: 'Unit Test'
  inputs:
  command: test
  projects: '**/Wintegrate.[Tt]est*/*.csproj'
  arguments: '--configuration $(buildConfiguration) '
  timeoutInMinutes: 5

They are failing for a couple of reasons

Failed   Wintegrate.Tests.BoomiRestClientTests.GetDeployedPackages
Error Message:
  Assert.Equal() Failure
Expected: OK
Actual:   0

and

Failed   Wintegrate.Tests.BoomiServiceTests.GetAtomsAndMolecules
Error Message:
  Newtonsoft.Json.JsonReaderException : Error reading JObject from 
  JsonReader. Path '', line 0, position 0.
Stack Trace:
  at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings 
  settings)
  at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings 
  settings)
  at Wintegrate.Domain.BoomiService.GetAtomsAndMolecules() in 
  d:\a\1\s\Wintegrate.Domain\BoomiService.cs:line 37
  at Wintegrate.Tests.BoomiServiceTests.GetAtomsAndMolecules() in 
  d:\a\1\s\Wintegrate.Tests\BoomiServiceTests.cs:line 53

The tests work fine when running locally from Visual Studio

1
could you try to run from the solution directly from your self hosted worker? Maybe dotnet missing something there.Mar Tin
@MarTin, Agree with Mar. This error doen not seem to come from the Azure Devops tool, more related to the project or the environment settings, so, try to run the test on the your agent server.Leo Liu-MSFT
Not Quite resolved yet, but i think your comments are right, i have flagged these as "Integration Tests" which has brought in a new question as to where you should run these tests in a CI pipeline and i need an on premises agent in order to be able to run them, but i digress. I guess your responses have answered the original question none the lessFrazer
@Frazer, Since this issue should not related to the external tools, like Azure Devops, more related to the the project or the environment settings. I convert the comment to answer, so it could help other community members who get the same issues. You can accept it as answer before you found the root cause for this issue. Looking forward to your sharing.Leo Liu-MSFT

1 Answers

1
votes

.NET Core XUnit Test Azure Dev Ops, Package Issues

According to the error message:

Failed Wintegrate.Tests.BoomiServiceTests.GetAtomsAndMolecules Error Message: Newtonsoft.Json.JsonReaderException : Error reading JObject from JsonReader. Path '', line 0, position 0. Stack Trace:

This error should not come from the Azure Devops tool or your build definition. It is more related to the project or the environment settings.

So, please try to run the test on the your agent server directly, and check if still have the same issue.

Hope this helps.