Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
102 views
in Technique[技术] by (71.8m points)

c# - Microsoft unit testing. Is it possible to skip test from test method body?

So I have situation when I need skip current test from test method body. Simplest way is to write something like this in test method.

if (something) return;

But I have a lot complicated tests and I need a way to skip test from methods which I invoke in current test method body. Is it possible?

question from:https://stackoverflow.com/questions/11650228/microsoft-unit-testing-is-it-possible-to-skip-test-from-test-method-body

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Further to other answers (and as suggested): I'd suggest using Assert.Inconclusive over Assert.Fail, since the original poster's situation is not an explicit failure case.

Using Inconclusive as a result makes it clear that you don't know whether the test succeeded or failed - which is an important distinction. Not proving success doesn't always constitute failure!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...