question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.BadImageFormatException when code coverage is enabled.

See original GitHub issue

I am trying to add code coverage to kubernetes-client-csharp.

Desperate of not having official support from Microsoft I am giving a try to coverlet. I’ve created a feature branch from project’s master and added Coverlet (everything fine in Travis so far.

But, as soon as I enable the “/p:CollectCoverage=true”, I start receiving the following error in 80% of tests we execute:

[xUnit.net 00:00:01.7251872]       System.BadImageFormatException : [/home/travis/build/sesispla/kubernetes-client-csharp/tests/bin/Debug/netcoreapp2.0/KubernetesClient.dll] No string associated with token.

Full log from faulty TravisCI job

We’re currently invoking the code coverage with this bash script:

#!/usr/bin/env bash

# Exit on any error
set -e

# Ensure no compile errors in all projects
dotnet restore
dotnet build --no-restore

# Execute Unit tests
cd tests
dotnet test --no-restore --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info
if [[ $? != 0 ]]; then
    exit 1
fi

Also happens locally with MacOS 10.12.6 High Sierra.

If I set /p:CollectCoverage=false tests passes properly in both TravisCI and locally.

Any clue on what’s going on?

Thanks you!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:25 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
tonerdocommented, Aug 11, 2018

@sesispla @queen-of-code this issue has been fixed in the latest release: https://www.nuget.org/packages/coverlet.msbuild/2.2.1, also includes your Include changes @pjanotti. Let me know if you run into any other issues

1reaction
tonerdocommented, Aug 18, 2018

That’s great to hear @sesispla! For the relative path issue, I ran into something similar in Coveralls. You need to go into your settings and set the repo root folder

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.BadImageFormatException when code coverage is ...
I am trying to add code coverage to kubernetes-client-csharp. ... System.BadImageFormatException when code coverage is enabled. #16.
Read more >
All unit tests throwing BadImageFormatException with Moq?
I'm using Moq v4.0. EDIT: Here is the full exception: Test method [ProductName and the method called] threw exception: System.
Read more >
How to fix System.BadImageFormatException
I have a project with a method that uses a DLL from another project. It used to work just fine, but now when...
Read more >
System.BadImageFormatException : An attempt was made ...
System.BadImageFormatException : An attempt was made to load - Hi I get the above errormessage when doing coverage with NUnit. Nunit on its...
Read more >
Problems with .NET unit testing
Exit code is 134 (Unhandled exception. System.BadImageFormatException: Could not load file or assembly '/Applications/Rider.app/Contents/lib/ReSharper.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found