Naming Test Methods

When I first started writing unit tests, I followed the common convention in C# for method naming:

WithdrawingMoneyShouldDecreaseBalanceByAmount

Later, I adopted the convention of separating words with underscores:

Withdrawing_Money_Should_Decrease_Balance_By_Amount

At some point I figured the approach above makes the name of the method look like the title of an article. I then decided to go with the same approach, but making everything lower case:

withdrawing_money_should_decrease_balance_by_amount

In some cases, I may use uppercase if I want to draw attention to something in particular:

withdrawing_money_should_DECREASE_balance_by_amount

I like when the code is calm to look at, and it draws my attention to things as appropriate.

Advertisements

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: