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

Tagging feedback #206

Open ben-foster-cko opened 5 years ago

ben-foster-cko commented 5 years ago

Hey guys,

We're looking at ways in which we can improve debugging in nspec especially for an individual example. One solution I've come up with is to extend the nspec base class with the following:

        public nspec()
        {
            _it = new ActionRegister((name, tags, action) => it[name, "debug"] = action);
        }

        public ActionRegister _it;

Then in the VS Code launch configuration providing the debug tag when calling dotnet run.

This is a bit of a precursor for a workshop I'm having with my team in Berlin next week as they have started putting some time into the VS Test Adaptor. One challenge with the adaptor is how to run a single example, without having to change the code like I'm doing above. Had you ever explored this? It would require each example to have some kind of identity within the context tree so that it can be identified at runtime.

GiuseppePiscopo commented 5 years ago

Just pasting here my (amended) twitter reply, to the benefit of public discussion:

Regarding what is already available, I remember two ways:

I don't know how/if things work in VS Code w.r.t. full VS.

Regarding new features, I'm ok to see a new one if that helps. Not sure what would you use, from the outside, as an identifier for a test case, apart from its "breadcrumb", so to say: context / subcontext / subcontext / it

amirrajan commented 5 years ago

System.Diagnostics.Debugger.Launch or roll your own Program.cs console app which is really simple:

https://gist.github.com/amirrajan/236cbaafef2c7c2195b47c41cbf9c918#file-program-cs

With building your own console app, you'd put the breakpoint in there and run that instead of using the nspec runner.