Never test intrinsic data instantiation

Test cases should never test intrinsic data instantiation within a class.  For example:

class ThisClass
   public const int BlockSize = 65536;  // Size of block used to read/write files.

In the past, I have seen some developers write unit test case code that does something like this:

ThisClass TC = new ThisClass();
if (TC.BlockSize != 65536)
   throw("BlockSize is not correct");

Test code like this is wasteful.  Only methods and constructors/destructors should be tested.  Intrinsic and even other data elements like containers or user defined classes should not be tested here.  Classes created by other developers should have their own unit tests written by those developers.

Prev          Next          Back to write the unit tests

Copyright 2011 by Robert G. Bryan

Leave a Reply

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

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