Importance of test data can not be emphasized enough whether we are writing automated or manual tests. With automated test we often deal with data objects. Data object is an object which encapsulates properties of data dealing with object. For example username and password could be encapsulated in to Credential object and passed on to required test methods.
But many a times we require default test data which can be used to facilitate system under test reach certain stage. How do we provide such default test data so that it is readily available for use? One way to deal with this is to use constructor on data object class which would initialize the data object with default data. In the following example TeamAttributes data object is initialized with default values -
Of course default values can also be read from a property file instead of being hardcoded as above :-)
And now if any of your test want to use default data then they can just instantiate data object class as-
What do you think of this approach of providing default test data? How do you handle default test data?
But many a times we require default test data which can be used to facilitate system under test reach certain stage. How do we provide such default test data so that it is readily available for use? One way to deal with this is to use constructor on data object class which would initialize the data object with default data. In the following example TeamAttributes data object is initialized with default values -
Of course default values can also be read from a property file instead of being hardcoded as above :-)
And now if any of your test want to use default data then they can just instantiate data object class as-
What do you think of this approach of providing default test data? How do you handle default test data?