views:

257

answers:

4

Hi all!

I have written unit tests under NUnit that use TestFixtures with different parameters. Now, when I run tests, I want to see with which parameters test has been passed and with which hasn't. Unfortunately, ReSharper shows only "Test failed: Child test failed" and no more information. Is there any way to see which parameters have caused test failure?

Thanks!

A: 

I assume your'e talking about the TestCaseAttribute, for a test like this:

[TestCase(true, Description = "When true")]
[TestCase(false, Description = "When false")]
[Test]
public void SomeTest(bool parameter) { . . . }

I use the Description property for this situation. With the description property, it will tell you which test case failed. If you described the situation well enough, it should be self-documenting.

Michael Hedgpeth
Tried your solution - still get the same problem. The only thing ReSharper can say is "Test failed: Child test failed". Can you provide simple code and screen shot of ReSharper's Unit Test Session Window output for this test?
levanovd
This no longer works for me. It had worked at some point. Sorry about that.
Michael Hedgpeth
+1  A: 

What version of ReSharper are you using?

Update:
I did some research and I don't think the TestCase attribute isn't supported in Resharper 4.X the way you would like it to be.

Apparently it is going to be supported in R# 5.X.

In the mean time there's a PlugIn for ReSharper called Gallio that might help.

Got the info from SO question here -> ReSharper Unit Test Runner - TestCase

Ralph Willgoss
I think that you have misunderstood the question. I know how to use asserts etc. The problem is that ReSharper doesn't show which TestCase has failed. It only shows that *one of the* TestCases has failed.
levanovd
yep, no probs - thats what I was trying to clarify. So you are wanting Resharper to pickup some Meta data after your tests run. See my new answer re: TestCase attribute and ReSharper
Ralph Willgoss
I'm using ReSharper 5.0 and this feature is not supported there. Hope that JetBrains takes care of this problem and will improve their tests runner in further versions.
levanovd
+1  A: 

Depends on how it's failing. In your Assert, the last parameter is an optional string, which you can place fail information in. ex: Assert.IsTrue(false, "Because I'm silly");

When your test fails, it will have your message right there.

Similarly, you can use Console.Write for test output. There should also be a call stack that describes where the test failed provided you don't catch and waste the exception.

Stefan Valianu
The issue is with Resharper not displaying which parameterized test fails. Putting an error message in the assert doesn't change that (I did check though.)
zcrar70
Oh I see. In that case you could always use reflection to spit out the information at run time.. although that is going a bit far >_>
Stefan Valianu
+2  A: 

I e-mailed JetBrains about this and received the following response from Andrey Serebryansky on July 9th, 2010:

This issue will be addressed in the next ReSharper release.

I believe the current release at the time of this writing is 5.1.


EDIT:

Based on comments by @Damien McGivern and @zcrar70

The issue is here, and it is fixed in the Resharper internal build.

However according to Victor Kropp (at the above link):

These changes will NOT be included in 5.1 due to technical reasons.

and when asked what the release date would be the response was (as of August 3, 2010):

I'm sorry, our roadmap is not yet established. I really don't know.

EDIT2:

More answers from Victor Kropp:

Q. Is there any update on a time line for when this will be in a release or nightly build that we can use?

A. ReSharper 6.0 EAP is expected to start before the end of year. I don't know actual date now.

Q. Will this bug fix be available in any release before 6.0?

A. No, sorry.

Lawrence Johnston
Good job, thank you!
levanovd
http://youtrack.jetbrains.net/issue/RSRP-179860?query=project:+ReSharper this is the issue in questionThe nightly builds for 5.1.1 http://confluence.jetbrains.net/display/ReSharper/ReSharper+5.1.1+Bugfix+Builds as of Aug 3rd don't have it :( so I think we'll have to wait.
Damien McGivern
The issue is tracked here: http://youtrack.jetbrains.net/issue/RSRP-147616 - the issue is apparently fixed, but no release date is planned currently.
zcrar70