2

Is there a way to end a mstest as passing prematurely and not run the rest of the test code?

Assert.Inconclusive comes the closest, but marks the test as inconclusive, which causes other issues for me (emails are generated based on the status of the test).

I am doing this, because I am running the mstest's code before the rest of the tests in the class, and don't want to run it when it runs normally. Basically this: https://groups.google.com/forum/?fromgroups=#!topic/specflow/6bzgl9LYOFI

EDIT: I found a way around this issue by ignoring the feature_setup portion so it will only run when I trigger it through reflection and be ignored as part of the normal mstest execution.

Sadly, this answer will only be applicable in the very specific case I have here using a combination of specflow and mstest. I think using return is the correct solution for a normal mstest.

Seth Micalizzi
  • 449
  • 6
  • 17
  • Why not just return early from the test method? – Frédéric Hamidi Mar 25 '13 at 19:13
  • Return what? Testmethods have a void return type. – Seth Micalizzi Mar 25 '13 at 19:28
  • 2
    I'm probably misunderstanding your question, but returning (nothing, just returning) from the test method would mark the test as passed since no assertion failed (unless the test expects an exception to be thrown, and in that case you only have to throw that exception early). – Frédéric Hamidi Mar 25 '13 at 19:29
  • I can't do this in this case, because I don't know the next step definition I am running. The detection of the method tag can only take place in the "BeforeScenario" method in specflow, or during code ran as part of every single step definition, adding return to BeforeScenario won't work. Adding code to not execute every step definition if the tag is present would be redundant and expensive. – Seth Micalizzi Mar 25 '13 at 19:54

0 Answers0