System.BadImageFormatException when code coverage is enabled.
See original GitHub issueI 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:
- Created 5 years ago
- Comments:25 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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 issuesThat’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