TLDR; I've got a mixed solution: NetStandard 2.0 for the library I'm actually developing and .Net Framework 4.6.2 (or alternatively dotnetcore 2.0) for the tests. How to configure travis.yml to build the library and the test project as well.
I'm actually working on a client for a rest api. I decided to use .NET Standard 2.0 as project type. As it is a REST based api, I decided to use Newtonsoft.Json to deserialize and serialize the content.
A problem occurred: the nuget package Newtonsoft.Json 10.0.3 doesn't support NetStandard 2.0 by now. But I found the commit ab3315f does. So I cloned the repo and build the netstandard library on my own as a workaraound till the new version is available in NuGet.
I added the project to CI system travis following this post: https://rimdev.io/building-net-core-on-travis-ci/
Now I added a test project to my solution using Nunit to run unit tests and integration tests for my library. No I'm facing 2 problems and I need to solve one:
problem 1: When my test project targets .NET Framework, I'm able to execute all the unit tests without any problems, but now travis complains based on my travis.yml there's no mono installed to build the complete solution correctly.
my question here: how to change my .travis.yml to build both project types within the solution.
problem 2: When my test project targets dotnetcore, my local build works, but when I try to execute tests locally, I get a runtime error:
System.IO.FileNotFoundException : Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=null'.
That's why I didn't test travis build by now, as I want to get it running locally first if this is the solution. I don't know why it doesn't find the dependency.
Any suggestions either for problem 1 or for problem 2?
I ended up adding NuGet package of Newtonsoft.Json 10.0.3 to my dotnetcore test project though it is not directly used there. Now the runtime error diappeared. So I am able to test locally and remotely as well and let travis CI build my project.
Related
Environment:
.Net Core 2.0
visual Studio Professional 2017
NUnit3
OpenCover (For code coverage)
ReportGenerator(For code coverage report)
Hi Nunit Team,
I am pretty familiar with MS Test framework and have worked on that extensively but was testing how suitable NUnit framework would be and so wanted to do a small POC around that. I created a small classlibrary and a unit test project. Below are the NuGet package been installed:
NUnit 3.7.1
But when I try to run the test cases from console runner like below I get exception saying System.Runtime, Version=4.2.0.0 assembly not found.
C:\Users\UN\.nuget\packages\nunit.consolerunner\3.8.0\tools>nunit3-console.exe D:\Code_Trials\BoMLibrary\BomTest\bin\Debug\netcoreapp2.0\BomTest.dll
Exception detail:
Errors, Failures and Warnings
Invalid : D:\Code_Trials\BoMLibrary\BomTest\bin\Debug\netcoreapp2.0\BomTest.dll
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
----> Could not load file or assembly 'System.Runtime, Version=4.2.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)
Run Settings
DisposeRunners: True
WorkDirectory: C:\Users\Smukherjee.nuget\packages\nunit.consolerunner\3.8.0\tools
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETCoreApp,Version=v2.0
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
NumberOfTestWorkers: 4
Am really not sure why so? No matter what I try not able to pass through this error. Moreover, when I try to install the assembly from Nuget I don't even find a assembly with version 4.2.0.0.
Tried installing the version 4.3.0.0 of System.Runtime but no luck. Can you please help on this.
Strange thing, I have got a sample unit test project (as part of opencover nuget install) which targets .Net Framework 4.5 and have NUnit2.6.7 package installed and when I try to run that using NUnit3 console it works like charm.
Even, installing NUnit3 latest stable version 3.10.1.0 doesn't help either. Also, it's surely not an Opencover issue since opencover console just passes the test run request to NUnit console. So the issue has to be around NUnit.
Let me know if you need more information around this.
Found the answer to this here https://github.com/nunit/nunit/issues/2763
NUnit Console doesn't run .NET Core tests - you need to use dotnet test instead. Take a look at this page:
https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard
I'm building a R# plugin and decided to cover it with tests. However, I noticed, that plugin tests cannot be run using the R# runner if plugin target version is the same as R# version.
For instance, if you try to run tests using JetBrains.ReSharper.SDK.Tests of version 2016.2.20160818.171542, you'll get the following error:
ERROR System.TypeLoadException:
Method 'RunTests' in type 'JetBrains.ReSharper.UnitTestRunner.nUnit26.BuiltInNUnitRunner' from assembly 'JetBrains.ReSharper.UnitTestRunner.nUnit26, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
In previous versions the error was different.
Likely, that happens because R# runner and SDK assemblies make a mix.
Is there any way to configure project/R# to be able to run plugin unit tests using the R# runner? Likely, R# dev team uses their own runner.
Thanks!
Unfortunately, this is a bug in the ReSharper runner in 201.6.2. Something to do with having multiple copies of the same assemblies in the same process - the assemblies from the install, and the assemblies from the bin folder. Something's getting messed up along the way.
You can subscribe to, vote and track this issue: RSRP-460399
The workaround is to install an older version of ReSharper into a Visual Studio "experimental instance" aka "custom hive", and use this instance to develop and test the plugin. The normal instance can be used for other day-to-day development.
You can download an older version of ReSharper here (e.g. 2016.1.2), and in the installer, click Options and enter the name of a custom instance, e.g. "Plugins". Then create a new shortcut to Visual Studio and set the command line to "devenv.exe /rootSuffix Plugins" (or whatever you called the custom hive).
R# and SDK must be either of different major versions, or of binary compatible versions. Unfortunately, within EAP the internal APIs inside the test runner have changed, so R# and SDK from different EAPs are not compatible.
I am using Microsoft Fakes for my unit testing. On my local dev machine, i can create a fake assembly of a class library and everything works fine. But when check-in the team build on the build server throws
"System.IO.FileLoadException: Could not load file or assembly 'Business.DataAccess.Core, Version=19.0.0.9999, Culture=neutral, PublicKeyToken=925fe695533b6fca' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
In my local dev machine 'Business.DataAccess.Core.dll' version is 19.0.0.9999, but on the build server it will be get a proper version number such as 19.0.0.1250.
Business.DataAccess.Core.fakes xml file is as follows. I have removed the version tag.
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="Business.DataAccess.Core" />
</Fakes>
I tried both by committing FakeAssemblies folder and not committing it. In both times its not working. My assumption was that fake assemblies will be created at compile time. But it's not working.
How can i get team build to run my unit tests using Microsoft Fakes.
When i fake just the EntityFramework.dll and commit the fake assemblies it works. This proves our build server is equipped with testing MS fakes. Build server has got VS 2013 ultimate version installed.
Much Appreciated!!!
The problem was with 'Business.DataAccess.Core.dll' getting a new version on the build server.
So, To fix this problem, removed 'GlobalAssemblyInfo.cs' file from the project and then in 'AssemblyInfo.cs' added a version.
I had to check-in FakeAssemblies folder with the fake assembly as well for this to work.
We have inherited a NetBeans Modules project (a.k.a. NetBeans Platform project) which builds using the NetBeans Ant tasks. We want to generate a code coverage report of the project to get an idea of what components are not being unit tested.
Generating a report is not part of the build process, it is simply something we want to do to understand the existing unit test coverage in the project.
We've decided to use JaCoCo to try and generate this. However the native support in NetBeans is for maven based projects. Unfortunately the TikiOne JaCoCoverage plugin currently does not support NetBeans Modules projects.
We are happy to just drive this via CLI to get an initial report. Does anyone have a success means of doing so under the given constraints?
Someone recently posted a related message to one of NetBeans mailing lists - https://netbeans.org/projects/platform/lists/dev/archive/2014-04/message/124
Short version: Cobertura plugin that does what you're looking for is not maintained now but you can build it and run it.
We have been successful in generating the report by doing the following:
Edited the project.properties file to run the JaCoCo agent when unit tests run. This is done by adding the following:
test.run.args=-javaagent:[yourpath/]jacocoagent.jar=destfile=[yourpath/]jacoco.exec
Use Netbeans to run the test task. This produces the jacoco.exec file.
Create a simple ant buildfile to generate reports from an .exec file (see this post)
Run the ant buildfile to generate the report.
I'm trying to work out how to run xUnit tests from TFS 2010.
I found some articles on how to achieve that with the older version (http://jonnekats.wordpress.com/2009/05/07/integrate-xunit-tests-into-your-daily-team-build/, http://weblogs.asp.net/mehfuzh/archive/2009/08/25/configuring-team-build-using-xunit.aspx).
These approaches don't work anymore with TFS 2010 because builds are no longer MSBuild files but instead are Workflows with different tasks.
What I would like to achieve is something similar to what I've got on my dev machine:
- build everything
- run the .xunit project file
- check the results
All that I can see on the web are custom build steps which I can't/won't use because I'll have to configure them for each single unit test assembly and they'll probably get completely messed up in TFS.
Any input would be appreciated.
Why dont use "InvokeProcess" in TFS Build workflow and invoke xUnit command line interface with the necessary xUnit project files as parameters?
You can capture the output of the command line by setting InvokeProcess->stdout to write a build message.
Take a look at the xUnit work item Support VSTS Test Runner on codeplex. You can find there a VS2010 extension in Beta version.