nspec / NSpec

A battle hardened testing framework for C# that's heavily inspired by Mocha and RSpec.
http://nspec.org/
MIT License
260 stars 57 forks source link

Any plans for updating this for latest version of .NET Core? #185

Open erlandsona opened 7 years ago

erlandsona commented 7 years ago

I'm using the current 1.0.1 version of the dotnet cli. And whenI run dotnet test I get this output

No test is available in /projects/unit-testing-using-dotnet-test/PrimeService.Tests/bin/Debug/netcoreapp1.1/PrimeService.Tests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.

All the examples from the docs use project.json / .xproj format for managing dependencies. I tried using dotnet's updater but it didn't work.

BrainCrumbz commented 7 years ago

Hi there

Are you working with a .NET Core project.json / .xproj project? As the library (actually the runners) do not support yet the recent .NET Core .csproj / msbuild project format arrived with VS2017.

erlandsona commented 7 years ago

It's a .NET Core with .csproj / msbuild. That's why I'm asking. But if I'm reading your comment correctly you're saying that the runners (like for xunit, nunit, etc...) haven't been updated yet?

So what's the timeline for the runners getting updated looking like?

stefanoric commented 7 years ago

+1

BrainCrumbz commented 7 years ago

"Yes and no."

.NET Core projects with .csproj / msbuild / VS2017 are not supported yet. When saying runners, those are only the NSpec runners, I'm not speaking about other test framework runners.

Available option today, for such a project, is to have a simple (.NET Core) console application acting as a custom runner. See e.g. Console App on website, or ping @amirrajan for some simple gist.

We have other "runners", like dotnet-test NSpec console runner and NSpec Visual Studio test adapter, but those have not been ported yet to the new setup. We plan to do that in the future, of course PR are more than welcome. HTH

amirrajan commented 7 years ago

+1 on just making a console app. I think you'll be happier in the long run. I'd be happy to work through any snags you have with getting one working.

stefanoric commented 7 years ago

@amirrajan what are the advantages of having a separate console app, as opposed to seemless integration with dotnet test?

amirrajan commented 7 years ago

advantages of having a separate console app

amirrajan commented 7 years ago

Aside: just noting that @BrainCrumbz likes editor and dotnet test integration. I'm not in any way trying to impede that work :-), just providing an alternative (or at least a work around till Microsoft figures out their tooling story for other testing frameworks).

stefanoric commented 7 years ago

I think most developers would prefer first-class integration with the tools they use every day. Working on a large team, it's best to have more options than fewer. Especially in the .NET world, most people live in the IDE, so they expect integration with Visual Studio, Resharper, etc...

I am in the process of shaping the template for how a lot of new asp.net core projects in our team will be developed. I am evaluating a few options for test frameworks, but at the moment the lack of integration with the 'Microsoft' way doing things is not playing in favor of NSpec, when some of the 'competitors' seem to be ahead in the game on dotnet core support. At the same time I like how nspec resembles Mocha in some way, and since we also do a lot of Node it has a great appeal.

If there's any way I can help, I am happy to evaluate if it's doable for me to help this going forward.

BrainCrumbz commented 7 years ago

Especially in the .NET world, most people live in the IDE, so they expect integration with Visual Studio, Resharper, etc...

We had already this chat with @amirrajan , it's somewhere in the issue history 😺 , all this is known and acknowledged since.

The NSpec features that are appealing to your team are the same that worked for us. We've been happily using it with VS2013 and VS2015 on classic .NET framework and, after migration, also on .NET Core project.json from dotnet-test console or VS2015.

Re. help, a couple of possibilities:

  1. Figure out what's the current story for test integration & runner in VS2017 + csproj .NET Core.
    There were docs at the time, before RTM Tooling, when Preview 2 Tooling and RC where still around, explaining communication protocol for dotnet-test integration, protocol also valid for VS integration. Know I don't know (yet) how things evolved. For command line, XUnit has moved to a completely owned CLI tool (like dotnet xnunit ....), I think bypassing dotnet test altogether. Don't know what did they do for VS2017 integration. Same thing for NUnit

  2. We're porting current VS adapter from VS2013 build environment to VS2015 one. After that, we'll be able to port the actual VSIX extension project to a format known to VS2017. And after this, there are more steps ... but this looks a bit hairy as a task I guess.

BTW thanks for your helpfulness

amirrajan commented 7 years ago

@stefanoric thanks for your input :-)

I completely understand the expectations for first class support in VS.

erlandsona commented 7 years ago

Okay, so I'm down with creating a console application, just not really sure how to follow the instructions when dotnet new consolegenerates a .csproj file instead of a project.json.

@amirrajan, @BrainCrumbz mentioned you could maybe post a simple gist to follow how to get this setup. Something like that would be much appreciated.

I'm new to C# coming from Ruby (so I'm still figuring out tooling), and being able to use something with contexts and an RSPec style DSL would help me out a ton.

amirrajan commented 7 years ago

@erlandsona: this should work: https://gist.github.com/amirrajan/236cbaafef2c7c2195b47c41cbf9c918#file-program-cs

amirrajan commented 7 years ago

@stefanoric: Other food for thought. Having console output (and not being constrained by the overhead of learning VS extension creation) lets me do crazy things like this: http://amirrajan.net/StackTracePreview/#/toc

ylelan commented 7 years ago

Same as amirrajan, working on .net core 2.0 on ubuntu machine. (gist updated on lower comment)

GiuseppePiscopo commented 7 years ago

@ylelan thanks for pointing that out. Actually yes, this.GetType()... does not fit well within a static method. You could swap that with the following: typeof(Program).... That should fit the bill, what do you think?

ylelan commented 7 years ago

Even better yes Gist updated https://gist.github.com/ylelan/a8af8e1816675d181d959de73822f1a0