org.infinitest.toolkit
Class GoldenMaster
java.lang.Object
org.infinitest.toolkit.GoldenMaster
public class GoldenMaster
- extends Object
"Golden master" testing is useful for recording the results of methods that are difficult to test, manually
verifying that the result meets expectations, and thereafter automatically verifying that the result continues
to meet those expectations.
Here's how to use this class:
Instantiate a "golden master" repository using at(File).
Use the following to record a complex value:
assertThat(complexValue, master.approving());
The test will fail, and will indicate what value was recorded. Manually verify this value.
When you are satisfied that the value is acceptable, call:
assertThat(complexValue, master.approved());
This will assert that the value matches the value recorded during the "approving" phase.
Any Serializable object can be recorded. "Golden masters" are recorded as files in directory
structures corresponding to the class/method in which they are used, beneath the directory given to the
"golden master" repository. You can use only one "golden master" in any given test method.
- Author:
- Paul Holser
|
Method Summary |
org.hamcrest.Matcher<Serializable> |
approved()
|
org.hamcrest.Matcher<Serializable> |
approving()
|
static GoldenMaster |
at(File aDirectory)
Creates and returns a new "golden master" repository on the file system rooted at the given directory. |
static GoldenMaster |
at(String directoryPath)
Creates and returns a new "golden master" repository on the file system rooted at the directory with
the given path. |
at
public static GoldenMaster at(String directoryPath)
- Creates and returns a new "golden master" repository on the file system rooted at the directory with
the given path.
- Parameters:
directoryPath - path to a directory to hold golden masters- See Also:
at(File)
at
public static GoldenMaster at(File aDirectory)
- Creates and returns a new "golden master" repository on the file system rooted at the given directory.
- Parameters:
aDirectory - the directory in which to deposit and retrieve "golden masters"
- Returns:
- a golden master repository
- Throws:
IllegalArgumentException - if the given directory does not exist, is not a directory, or cannot
be read from or written to
approving
public org.hamcrest.Matcher<Serializable> approving()
- Returns:
- a matcher which, when triggered, records the value it is asked to match, and fails the calling
test with a message that indicates that the value should be manually verified.
- Throws:
AssertionFailedError - always
approved
public org.hamcrest.Matcher<Serializable> approved()
throws IOException
- Returns:
- a matcher which, when triggered, compares the value it is asked to match against a previously
recorded value, failing the calling test if the values are not equal.
Arrays are compared via
Arrays.equals(Object[], Object[]).
- Throws:
AssertionFailedError - if recorded value and new value do not match
IOException
© Copyright 2009 Paul R. Holser, Jr. All rights reserved. pholser@alumni.rice.edu