I have an xUnit Test Project with the following project.json:
"dependencies": {
"xunit": "2.1.0-beta2-*",
"xunit.runner.dnx": "2.1.0-beta2-*"
},
"commands": {
"test": "xunit.runner.dnx"
},
"frameworks": {
"dnx451": { },
"dnxcore50": {
"dependencies": {
"System.Collections": "4.0.10-beta-22816",
"System.Linq": "4.0.0-beta-22816",
"System.Threading": "4.0.10-beta-22816",
"Microsoft.CSharp": "4.0.0-beta-22816"
}
}
}
My Buildserver is able to build everything correctly, but it gives me the following message by trying to test:
2015-05-17T18:41:26.0903225Z Warning: No test is available in C:\TfsData\Build\_work\c55817e8\...\artifacts\bin\
My Buildserver runs with TFS2015 and I installed VisualStudio 2015RC. I found similar questions, but only about TFS2013, which doesn't help me, because there is no TestAgent in TFS2015. Nowadays the xUnit-"Util" is included with NuGet via json file.
Testing with VisualStudio works fine, even at the server installation of VS.
Can someone give me a hint, how to fix that issue, please?
The DNX support in Visual Studio has very likely not made it to TFS Build yet. It does not use the standard test discovery of other xUnit.net test types, but rather something the ASP.NET team added to Visual Studio to support unit tests in any project.json-based project.
Related
I'm using dotnet to run my unit tests in xUnit.
In one of my unit tests I get a Stackoverflow. How do I determine which unit test causes this?
Project.json (relevant parts):
"dependencies": {
"NLog": {
"target": "project"
},
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
},
"testRunner": "xunit",
"frameworks": {
"net451": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1"
}
}
}
Running:
> dotnet test
Current result:
xUnit.net .NET CLI test runner (64-bit Desktop .NET win81-x64)
Discovering: NLog.UnitTests
Discovered: NLog.UnitTests
Starting: NLog.UnitTests
Process is terminated due to StackOverflowException.
SUMMARY: Total: 1 targets, Passed: 0, Failed: 1.
I'm using xUnit to run unit tests under .NET Core and .NET 4.5.1 (currently only .NET 4.5.1 used in the example)
PS: dotnet test --verbose does not exists
Found it by running the test in Visual Studio. The GUI makes it clear which test was the issue.
I want to learn fsharp. So I'm looking at exercism.io
In their readme they instruct to use Xamarin Studio for running the test
http://exercism.io/languages/fsharp/tests
But I would like to just run the tests from the terminal. The exercises from exercism only include one F# file e.g. HelloWorldTest.fs.
This answer Running tests on Mac OS X console using mono/nunit-console/4 instructs to run nunit-console with a .csproj or .dll file. But these files are not present in the exercism files. So I'm not clear what to do.
I have install mono using homebrew.
How do I run the NUnit test from the terminal in OSX?
You may have to use xbuild on the command line to compile the fsproj file then the resulting dll can be executed with nunit on the commandline also.
If you don't have the fsproj you can use fsharpc on the file directly then call nunit, remembering to use mono to execute nunit.
fsharpc HelloWorldTest.fs
mono nunit-console.exe HelloWorldTest.exe
Sorry am not in a position to test this, but should be something like this.
I figured out how to do this:
1. install dotnet as described https://www.microsoft.com/net/core#macos
2. In the folder of the exercise run
dotnet new --lang f#
3. Rename Program.fs to the name of the exercise e.g. HelloWorld.fs
4. Change project.json to
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"compilerName": "fsc",
"compile": {
"includeFiles": [
"HelloWorld.fs",
"HelloWorldTest.fs"
]
}
},
"dependencies": {
"NUnit": "3.4.1",
"dotnet-test-nunit": "3.4.0-beta-2"
},
"tools": {
"dotnet-compile-fsc": "1.0.0-preview2-*"
},
"frameworks": {
"netcoreapp1.0": {
"imports": "portable-net45+win8",
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
},
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629"
}
}
},
"testRunner": "nunit"
}
This includes the nunit dependency.
Note includeFiles, this should include the source code file for the exercise and the test file. e.g. HelloWorld.fs and HelloWorldTest.fs
5. Install required packages by doing
dotnet restore
6. Add your code to the previously renamed source file e.g. HelloWorld.fs
7. Finallly, run test by doing
dotnet test
I'm targeting dotnet-test-mstest": "1.0.1-preview on dotnet core rc2 in my test project.
Edit:
Okay. I'm targeting the the desktop .NET. But this should not make any difference.
project.json
{
"version": "1.0.0-*",
"testRunner": "mstest",
"dependencies": {
"Betgame": "1.0.0-*",
"dotnet-test-mstest": "1.0.1-preview",
"MSTest.TestAdapter": "1.0.0-preview",
"MSTest.TestFramework": "1.0.0-preview",
"NETStandard.Library": "1.5.0-rc2-24027"
},
"frameworks": {
"net461": { }
}
}
output when running dotnet test looks quite good!
How can i get the output as a xml file to process this in my build process? Any ideas? Or is it just not yet supported?
So far i tried dotnet test -xml test-results.xml but no output was generated.
Thank you for trying out the MSTest release.
Please use the following to generate a trx report (xml file):
vstest.console.exe project.json /UseVsixExtensions:true /logger:trx
The report gets generated in a TestResults folder.
Looking at the decompiled code of dotnet-test-mstest, I don't see any -xml option or anything similar. So I think it's not currently supported.
I'm upgrading from asp.net mvc 4, asp.net webforms, Ef 5 and MEF 1 to dotnet core.
despite existing code, that they decided to not support in dotnet core and i need to read many places to found what is going on dotnet corefx development, one of my big problems is that i don't understand vs 2015's system of adding dependency and etc.
i'm going to use MEF2(System.Composition), simply because it seems the MEF1(System.ComponentModel.Composition) is not going to be implemented in dotnet core. so i created a project of class library(package) in vs2015 as follow:
and then typed :
Install-Package Microsoft.Composition
into PM.
now, my project.json file looks like this:
{
"version": "1.0.0-*",
"description": "___ Class Library",
"authors": [ "___" ],
"tags": [ "" ],
"frameworks": {
"net451": {
"dependencies": {
"Microsoft.Composition": "1.0.30"
}
},
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
}
}
the problem is that : is this a dnx project that only used dnx packages? and yes, the project's file extension is .xproj.
to me it seems that i'm using full .net framework 4.5.1 implementation of MEF2.
also here is a link Using System.Composition in dotnet corefx page that i don't found any useful info on it.
is this means that they dont implemented the MEF2 in dotnet corefx yet?
Replace "dotnet5.4" for "dnxcore50". Yes, MEF 1 won't be supported, only MEF 2.
I wrote a post about using it, which you can find here: https://weblogs.asp.net/ricardoperes/using-mef-in-net-core.
I am trying to create a new web application using OS X and VS Code from scratch without using any scaffolding tool. My starting point is Scott Allen's tutorial on pluralsight:
https://app.pluralsight.com/library/courses/aspdotnet-core-1-0-fundamentals/table-of-contents
My project structure is:
The global.json file contains
{
"projects": [ "src" ],
"sdk": {
"version": "1.0.0-rc1-update2"
}
}
And the project.json currently contains
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": false
},
"dependencies": {
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.Hosting": "1.0.0-rc1-final"
},
"frameworks": {
"dnx451": {},
"dnxcore50": {}
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5000"
},
"exclude": [
"wwwroot",
"node_modules"
]
}
I have run dnu restore to get the packages and now I would like to run the web. I need to go to the web app folder and run dnx web in order to do so and the app starts
Is it possible to run the application directly from the root folder, not from the web app folder? Is the global.json file needed in such setup? And how do I change the hosting environment? I have gone through the documentation, but the hosting environment is only clear when using VS 2015.
You cannot simply run from the root because there could be multiple projects that are "executable". But you can pass the project to dnx using the --project/-p argument.
The environment is set using the ASPNET_ENVIRONMENT environment variable.
The global.json file is useful for two things:
The sdk section is only by VS.
The projects section is used all the time and it's useful if you have the projects in multiple folders (for example src and test). If everything is in a single folder, you don't need it.
So, the bare minimum in order to run an web application is:
A folder for your project
A project.json file
A startup file