-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue when running a test project targetting a Web API. #184
Comments
@mailbala: Can you share with us a repro project please? |
@AbhitejJohn I figured out the issue. I have a class library dependency for the webapi proj which was targeting netstandard1.5. When I changed to netstandard1.4, tests are running successfully. Thanks! |
@mailbala : That seems more of a workaround to me. From here net461/net462 should be compatible with netstandard1.5. What is your unit test project targeting? |
@AbhitejJohn unit test project is targeting net462. Message: Initialization method StackTrace: |
Saw an instance of a similar issue here: dotnet/standard#295 . Does that help? Seems more of a .Net dependency resolution issue, so you might want to get help from the experts in the dotnet repo as well. |
@AbhitejJohn I tried to refer NETStandard.Library library in net462 unit test project. But faced the same issue |
@mailbala : I took a deeper look at this and this was pretty straight forward to repro. This has been fixed here: microsoft/vstest#428 and should work with the latest pre-release version of Microsoft.Net.Test.Sdk. Do feel free to re-open this issue if the above does not work for you. |
The WebAPi project targets net462 and Output type is exe . In the unit test project, I am using NSubstitute to mock the dependencies. When I run the test, I am getting the below error
Message: Initialization method WebApi.UnitTest.Controllers.HomeControllerV1Test.TestInitializer threw exception. System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).
When I use Moq, getting the below error.
Message: Test method WebApi.UnitTest.Controllers.HomeControllerV1Test.TestUserList threw exception:
System.BadImageFormatException: Could not load file or assembly 'CustomerInsights.WebApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
The text was updated successfully, but these errors were encountered: