What's the appropriate naming macro for this unit test?

Coordinator
Jul 8, 2011 at 11:31 AM

Hi Herman,

I guess in your case you should have only one macro:
$(AaBb)_$(AaBb)_$(AaBb)

It will ensure that any unit test name:

  • contains exactly 3 parts separated by underscore
  • in each part there are PascalNames

So, the following will fail:

ValidateUrlEmpty
Validate_UrlEmpty
Validate__UrlEmpty_ExceptionThrown

and the following will pass:

Validate_UrlEmpty_ExceptionThrown
Validate_Url_Empty (as a side effect, but it seems OK)

 

Moreover, if you have limited number of "expected behaviour", you could even make something like this:
$(AaBb)_$(AaBb)_$(AaBb)ExceptionThrown
$(AaBb)_$(AaBb)_$(AaBb)Passed

... which will make your naming even more strict.

Good luck!

Best regards,
Oleg Shuruev

Coordinator
Jul 8, 2011 at 11:35 AM

Just some clarifying.

With $(AaBb)_$(AaBb)_$(AaBb) the following will not pass:

public void Validate_Url_Empty_Argument_Exception_Thrown()

If you want to allow it too, you should also add $(Aa_Bb) as a separate line (in rule definition).
Hope that makes it more clear.

Best regards,
Oleg Shuruev