microsoft / testfx

MSTest framework and adapter
MIT License
714 stars 253 forks source link

Add Assert.Pass() #692

Closed HeroMaxPower closed 4 years ago

HeroMaxPower commented 4 years ago

MSTestv2 has Assert.Fail() so we should be catering for the other end of the coin.

Of course this is a discussion as this could be seen as a anti-pattern however other frameworks support this such as NUnit.

I could try to implement something, but before i do i wanted to discuss with the wider community and Microsoft Staff,

nohwnd commented 4 years ago

To me this seems like an unnecessary change. The way most test frameworks work is that every test will start as a passing test, and fail only if an exception is thrown. From a high-level point of view this is a bit backwards, because your starting point (where you have no-code in the test), is the same as your goal (where you have some code in the test and it passes).

If I'd be inventing testing now, I would start from "inconclusive" and would only prove the test to be passing by passing an assertion, or failing by failing an assertion / throwing exception (and now I need to write and popularize a whole new testing framework :D).

But that is not how it works in most frameworks, including mstest. If we added Assert.Pass() the only place where I see it being used is to short-circuit a test, but then we would communicate that the test passed, but in reality it was skipped, and we already have a state for that.

HeroMaxPower commented 4 years ago

I agree with the points above. The only purpose it serves is shortens test case creation in control flow in test design such as switch statements. If your points aren't written down i'd recommend stating this intention as i predict this will be asked again somewhere down the line.

nohwnd commented 4 years ago

Would that be any different from a simple return?

...this will be asked again somewhere down the line.

Might be, and there might be the same answer in the history of the issues, I actually did not search for it. I just don't think this change would bring enough value to make it worth the effort to document it, support it and explain it, and would end up just bloating the api. 🙂

nohwnd commented 4 years ago

and now I need to write and popularize a whole new testing framework :D

I actually did.

https://github.com/nohwnd/Intent

HeroMaxPower commented 4 years ago

I'll close this issue unless anyone want to change their minds :)