Google-Apps
Hauptmenü

Post a Comment On: the urban canuk, eh

"TDD Tips: Test Naming Conventions & Guidelines"

8 Comments -

1 – 8 of 8
Blogger Jason Young said...

This is actually really good. It's a great starting point when establishing the unit test standards and your organization.

8:58 AM

Anonymous Anonymous said...

w/r/t: "AVOID: Using underscores as word-separators"

Saving time by not having to hit the Shift key is so not a reasonable argument against using a naming-style that increases solubility as much names_with_underscores_does. Especially if you use something like AutoHotKey (http://www.jpboodhoo.com/blog/BDDAutoHotKeyScriptUpdateTake2.aspx) to replace a space with an underscore for you! :)

I'm not saying that PascalCasing is bad or that it should be avoided, I'm only saying that using underscores is equally viable... and IMO, a more readable style. I find this especially true when used with some of the newer BDD frameworks that can generate HTML reports from your Test/Spec names.

9:30 AM

Blogger bryan said...

Steve, I probably could have elaborated better on the underscore recommendation. I'll admit the motivator of not having to hold down the shift key is poor.

My motivation is that your tests are different than your API for your production code in that Test names have a tendency to change over their lifetime. As a personal preference, I find methods with underscores clunky and I rely on tools to create them for me (creating event handlers, etc) rather than type them by hand.

Honestly, any style will do (compared to not writing tests) and if you have tools that work well with that style, then you might enforce that style as a recommendation within your organization.

I should probably amend the list, and replace that AVOID with a recommendation to pick a consistent style that is easily understood and flexible to change.

9:55 AM

Anonymous Anonymous said...

>> replace that AVOID with a recommendation to pick a consistent style that is easily understood and flexible to change.

Now that is something I can get on board with. :)

8:31 AM

Blogger Afzi said...

How does TDD influence the way we write objects? Could you give some insight on this as well please?

3:36 PM

Blogger bryan said...

That's an interesting question Afzi: TDD does impact the way we write code, but expressing it as do-n-don't would fall under a different category than those listed here. I'll chew on that, maybe post something in the future.

Generally speaking, I think TDD discourages "blackbox" code, where code is organized to do anything and everything without sharing any details of how it will perform those tasks. TDD in contrast, the focus is on writing testable code, so you end up with open-ended, cohesive sets of specialized objects. Each set of objects can be tested independently of each other and can also be substituted with test versions to assist in testing larger related components. TDD and Inversion of Control / Dependency Injection go very well together.

2:38 PM

Blogger cliff said...

you need to update your list of points above. You should refer to "TestFixtureSetup/TestFixtureTearDown" instead of "SetupFixture/TearDownFixture"

2:54 PM

Blogger bryan said...

Thanks for pointing that out cliff. I wish my blog writer had intellisense.

1:48 AM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot