If you were writing a postcode class with basic validation, this is one point you might reach along your journey. This illustrates one approach to removing duplication from a test.
Note that duplication has been minimised in the 'validPostCodes' scenarios. To ensure that failure messages identify the input that has caused the failure, the 'failure reason' argument in assertThat( String reason, T actual, Matcher<T> expected)
has been used. Without this 'reason' it would not be apparent which of the input examples caused the test to fail.
This is incomplete and does not support all postcode formats nor does it handle all exception cases.
This example created by @antonymarcano and @jamesmartin