use of org.junit.experimental.theories.Theory in project junit4 by junit-team.
the class ParameterizedAssertionErrorTest method sameHashCodeWhenEquals.
@Theory
public void sameHashCodeWhenEquals(Throwable targetException, String methodName, Object[] params) {
ParameterizedAssertionError one = new ParameterizedAssertionError(targetException, methodName, params);
ParameterizedAssertionError two = new ParameterizedAssertionError(targetException, methodName, params);
assumeThat(one, is(two));
assertThat(one.hashCode(), is(two.hashCode()));
}
use of org.junit.experimental.theories.Theory in project junit4 by junit-team.
the class WhenNoParametersMatch method showFailedAssumptionsWhenNoParametersFound.
@Theory
public void showFailedAssumptionsWhenNoParametersFound(int data, Matcher<Integer> matcher) throws Exception {
assumeThat(data, not(matcher));
AssumptionsFail.DATA = data;
AssumptionsFail.MATCHER = matcher;
String result = testResult(AssumptionsFail.class).toString();
assertThat(result, containsString(matcher.toString()));
assertThat(result, containsString("" + data));
}
use of org.junit.experimental.theories.Theory in project junit4 by junit-team.
the class PrintableResultTest method includeMultipleFailures.
@Theory
public void includeMultipleFailures(String secondExceptionName) {
PrintableResult backtrace = new PrintableResult(Arrays.asList(new Failure(Description.createSuiteDescription("firstName"), new RuntimeException("firstException")), new Failure(Description.createSuiteDescription("secondName"), new RuntimeException(secondExceptionName))));
assertThat(backtrace.toString(), containsString(secondExceptionName));
}
use of org.junit.experimental.theories.Theory in project junit4 by junit-team.
the class PrintableResultTest method backTraceHasGoodToString.
@Theory(nullsAccepted = false)
public void backTraceHasGoodToString(String descriptionName, final String stackTraceClassName) {
Failure failure = new Failure(Description.createSuiteDescription(descriptionName), new Throwable() {
private static final long serialVersionUID = 1L;
@Override
public StackTraceElement[] getStackTrace() {
return new StackTraceElement[] { new StackTraceElement(stackTraceClassName, "methodName", "fileName", 1) };
}
});
assertThat(new PrintableResult(asList(failure)).toString(), allOf(containsString(descriptionName), containsString(stackTraceClassName)));
}
use of org.junit.experimental.theories.Theory in project neo4j by neo4j.
the class PagedByteChannelsTest method mustCloseCursorOnClose.
@Theory
public void mustCloseCursorOnClose(ThrowingFunction<PagedFile, ? extends Channel, IOException> channelConstructor) throws Exception {
AtomicInteger closeCounter = new AtomicInteger();
PagedFile pf = new StubPagedFile(8192) {
@Override
public PageCursor io(long pageId, int pf_flags) throws IOException {
return new DelegatingPageCursor(super.io(pageId, pf_flags)) {
@Override
public void close() {
super.close();
closeCounter.getAndIncrement();
}
};
}
};
channelConstructor.apply(pf).close();
assertThat(closeCounter.get(), is(1));
}
Aggregations