tags:

views:

90

answers:

3

We're using very descriptive test names for work and it's getting very annoying to horizontally scroll across them. Is there a way to get a method name to span multiple lines in C#?

Something like:

MyMethodNameIsReallyLong
    _SoImMakingItSpanMultipleLines
    _SoIDontHaveToHorizontallyScroll
    _AndMyLifeIsMuchEasier()
{
    DoSomething();
}

Thanks.

+1  A: 

why choose so much lengthy names. length of the first one is enough to understand MyMethodNameIsReallyLong. Function name should be combination of max 4-5 different words which could be understandable. Such lengthy names should be avoided.

existing examples getElementById/Name - javascript

Amit Ranjan
Should this be a comment perhaps? I was going to post something similar but does not answer question asked!
Peter Kelly
Disagree. He is asking about Test methods. They should be long and descriptive. MakeSureItDoesntBlowUp is not nearly as helpful as 'When_Passing_Both_Null_Values_Make_Sure_It_Exits_Gracefully'
Mike M.
+1 for Peter. yes it should be. But what i know is that, funtion name should be descriptive from its name , not all lengthy names are descriptive as they stated for test conditions. like MyMethodNameIsReallyLongSoImMakingItSpanMultipleLinesSoIDontHaveToHorizontallyScrollAndMyLifeIsMuchEasier() instead we can use TestMethodBrokenForMakingLifeEasier()
Amit Ranjan
A: 

I assume the individual method names are not long enough to require scrolling. If you rearrange the method calls, you'll see more text vertically:

MyMethodNameIsReallyLong(
   SoImMakingItSpanMultipleLines(
      SoIDontHaveToHorizontallyScroll()
   )
);
mcandre
I think you're on the wrong track. OP's one method name is:MyMethodNameIsReallyLongSoImMakingItSpanMultipleLinesSoIDontHaveToHorizontallyScrollAndMyLifeIsMuchEasier()
JeffH
+4  A: 

I'm pretty sure the short answer is: No.

There is a Description Attribute for TestMethod that "might" be a helpful alternative...

[TestMethod, Description("My really long descriptive test name")]
public void Test99()
{
   Assert.Fail();
}
Scrappydog
Or simply (XML) comment the method...
Noldorin
This could help when writing tests. Additionally, when running tests, the things that matter most are which test failed and why. In short, the test name can still be terse as you mentioned, and the test's assert messages could be very long and descriptive.
Phil Gilmore