machine / machine.specifications

Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
MIT License
885 stars 178 forks source link

MSpec VS Test Adapter executes Establish and Because for each It assertion instead of once #340

Closed justinstenning closed 7 years ago

justinstenning commented 7 years ago

Sorry if this is the wrong spot, but the MSpec VS Test Adapter repo didn't have issues enabled.

I recently wrote an MSpec test case where the action takes place and I need to check multiple assertions. It appears that the "Establish" context and "Because" is run once for each "It" assertion within the MSpec VS Test Adapter (at least while debugging).

My understanding was that the context and action should only be executed once for the set of assertions for a particular Mspec class. Is my understanding correct? And if so is this therefore a valid bug with the MSpec VS Test Adapter, or is this a result of some limitation within the VS2017 test environment?

ivanz commented 7 years ago

It looks like this is the same issue as #325 . Due to the way Visual Studio invokes the test run and the protocol between the test runners and mspec - at the moment it seems like we end up executing each "It" as its own test run when Debug Selected is used instead of Debug All. In the latter case this doesn't happen.