Stackoverflowexception with xUnit and dotnet CLI - which test? - stack-overflow

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.

Related

Displaying Spectron-Webdriverio test results in TeamCity

I would like to display Spectron test results in TeamCity. I have followed the instructions at the Webdriverio TeamCity Reporter page, which are:
npm install wdio-teamcity-reporter --save-dev
and creating a wdio.conf.js file:
exports.config = {
reporters: ['teamcity'],
}
I have placed this file at the top of the project. It has no other entries; I've never needed it before.
I have also tried the additional configuration suggested at wdio-teamcity-reporter npm page.
This is the Jest object in package.json:
"jest": {
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"transform": {
"\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"roots": [
"<rootDir>/__tests__/",
"<rootDir>/components/"
],
"modulePaths": [
"<rootDir>/__tests__/",
"<rootDir>/components/"
],
"testMatch": [
"**/?(*.)(spec|test).(ts)?(x)"
]
}
And this is the relevant command (that TeamCity calls) in package.json:
"scripts": {
// ...
"test": "jest --maxWorkers=1 --forceExit",
// ...
},
This testing project is built with Typescript and Jest, and only comprises the e2e Spectron tests for an Electron app. The build artifact for that app is a TeamCity dependency for my test 'build'. In my build, TeamCity installs the app, runs the Spectron tests (which are passing), and then uninstalls the app.
All I can see at the moment is the Jest console output within the build log. While there are some hidden artifacts, I see no normal artifacts. I was thinking that the reporting package should have produced an html artifact. How do I go about displaying a test tab, or some other useful set of results?
It turns out that Jest can collect all the Webdriver results. Try using https://www.npmjs.com/package/jest-teamcity.
In jest.config.js use:
"testResultsProcessor": "jest-teamcity"

How to run fsharp test on Mac from terminal?

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

MSTest no xml output on .NET Core RC2

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.

System.Composition in dotnet corefx, is it used full dotnetframework?

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.

xUnit with TFS2015 and VisualStudio2015 doesn't find any test

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.

Resources