protected void reportParameterizedError(Throwable e, Object... params) throws Throwable { if (params.length == 0) { throw e; } throw new ParameterizedAssertionError(e, fTestMethod.getName(), params); }
@Theory public void equalsReturnsTrue(Throwable targetException, String methodName, Object[] params) { assertThat(new ParameterizedAssertionError(targetException, methodName, params), is(new ParameterizedAssertionError(targetException, methodName, params))); }
@Test public void canJoinWhenToStringFails() { assertThat(ParameterizedAssertionError.join(" ", new Object() { @Override public String toString() { throw new UnsupportedOperationException(); } }), is("[toString failed]")); }
@Theory public void equalParameterizedAssertionErrorsHaveSameToString( ParameterizedAssertionError a, ParameterizedAssertionError b) { assumeThat(a, is(b)); assertThat(a.toString(), is(b.toString())); }
@Theory public void differentParameterizedAssertionErrorsHaveDifferentToStrings( ParameterizedAssertionError a, ParameterizedAssertionError b) { assumeThat(a, not(b)); assertThat(a.toString(), not(b.toString())); }
@Theory(nullsAccepted = false) public void buildParameterizedAssertionError(String methodName, String param) { assertThat(new ParameterizedAssertionError(new RuntimeException(), methodName, param).toString(), containsString(methodName)); }
@Theory public void isNotEqualToNull(ParameterizedAssertionError a) { assertFalse(a.equals(null)); }