Gold standard tests

Gold standard tests, or characterization tests, are those tests that simply define the expected functionality of a method. If you were to add tests to a legacy system, you would likely begin by writing gold standard tests to define the "happy path" through the system. You might run the application to determine what values a given method returns based on a given input, and then write a test to duplicate the results.

Gold standard tests are used because they provide a shortcut. Normally, to test legacy code, you would have to abstract third-party libraries and set up dependency injections of some sort. You may also have to refactor the code significantly just to get to the point where you can test anything. By using a gold standard test, most of this work can, temporarily, be bypassed. The only abstractions needed are screen output, date/time, and random. Just about everything else can be used as is.

This would provide a baseline for a suite of tests and help ensure that expected functionality does not change with future refactoring or modifications. Gold standard tests do not validate correctness; they merely confirm that the system does what the system did.

As a basis, gold standard tests provide a certain level of comfort to guard against any unwanted behavior changes. These likely will not be enough to provide adequate code coverage and should have additional tests added to cover edge cases and alternate paths through the system.

As the test suite grows and the coverage becomes more meaningful and complete, it may prove wise to remove the original gold standard tests. Again, you want your test suite to be able to execute quickly so that it is run always and often. Removing tests that may be superfluous will help minimize the feedback cycles when running your tests. In other words, you will know if you have broken something faster and will be more likely to run the tests if the tests complete faster. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.212.124