What Makes A Good Test – Independent

This is a big topic, I have to admit. Whenever we start to talk about this topic, it’s endless and interesting. I would like to share my views in a set of blogs, this is the first one, focusing on “Independent”.

“Independent” is not a stand-alone attribute of test, it’s actually related with maintenance and cost, as well as the life-cycle of the test. The sort of detail in a test actually creates a dependency on the internal structure of the object being tested. This dependency means if there is any other requirement change that will impact the implementation, such as change from “Array” to “Map”, this test will fail, even though the behaviour of the object does not change.

This brittleness actually makes test suits much more expensive to maintain, and is the primary reason for test suites to become ignored and, ultimately, discarded.

Here are several tips to make the test more independent:

  • Focus on behaviour, not structure;
  • Understand the constraint, such as environment related;
  • Reasonable testing abstract; promote code reuse;
  • Sensitive to environment, centralize the management;
  • Make the test easy to assemble;
  • Avoid using hard-code.
  • Appropriately divide the test into different levels, unit->function->integrated->system->regression->performance->stress.

One Response to What Makes A Good Test – Independent

  1. Pingback: What Makes A Good Test – Visible « About life

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: