use of org.junit.runner.JUnitCore in project mockito by mockito.
the class UnusedStubsExceptionMessageTest method lists_all_unused_stubs_cleanly.
@Test
public void lists_all_unused_stubs_cleanly() {
JUnitCore runner = new JUnitCore();
//when
Result result = runner.run(HasUnnecessaryStubs.class);
//then
Failure failure = result.getFailures().get(0);
assertEquals("\n" + "Unnecessary stubbings detected in test class: HasUnnecessaryStubs\n" + "Clean & maintainable test code requires zero unnecessary code.\n" + "Following stubbings are unnecessary (click to navigate to relevant line of code):\n" + " 1. -> at org.mockitousage.junitrunner.UnusedStubsExceptionMessageTest$HasUnnecessaryStubs.<init>(UnusedStubsExceptionMessageTest.java:0)\n" + " 2. -> at org.mockitousage.junitrunner.UnusedStubsExceptionMessageTest$HasUnnecessaryStubs.<init>(UnusedStubsExceptionMessageTest.java:0)\n" + "Please remove unnecessary stubbings or use 'silent' option. More info: javadoc for UnnecessaryStubbingException class.", filterLineNo(failure.getException().getMessage()));
}
use of org.junit.runner.JUnitCore in project mockito by mockito.
the class VerificationListenerCallBackTest method should_call_verification_listeners.
@Test
public void should_call_verification_listeners() {
//given
RememberingListener listener = new RememberingListener();
MockitoFramework mockitoFramework = Mockito.framework();
mockitoFramework.addListener(listener);
JUnitCore runner = new JUnitCore();
//when
runner.run(VerificationListenerSample.class);
//then
assertThat(listener.mock).isNotNull();
assertThat(listener.mode).isEqualToComparingFieldByField(times(1));
}
use of org.junit.runner.JUnitCore in project mockito by mockito.
the class VerboseMockitoRunnerTest method shouldNotContainWarnings.
@Test
@Ignore
public void shouldNotContainWarnings() throws Exception {
Result result = new JUnitCore().run(NoWarnings.class);
assertEquals(1, result.getFailures().size());
assertEquals("boo", result.getFailures().get(0).getException().getMessage());
}
use of org.junit.runner.JUnitCore in project mockito by mockito.
the class InvalidUseOfMatchersTest method should_mention_matcher_when_misuse_detected.
@Test
public void should_mention_matcher_when_misuse_detected() {
// Given
// When
Result run = new JUnitCore().run(ObjectMatcherMisuseOnPrimitiveSite.class);
// Then
assertThat(run.getFailures()).hasSize(2);
assertThat(run.getFailures().get(0).getException()).isInstanceOf(NullPointerException.class).hasMessage(null);
assertThat(run.getFailures().get(1).getException()).isInstanceOf(InvalidUseOfMatchersException.class).hasMessageContaining("primitive alternatives");
new StateMaster().reset();
}
use of org.junit.runner.JUnitCore in project junit4 by junit-team.
the class CategoriesAndParameterizedTest method runsTestMethodWithCategory.
@Test
public void runsTestMethodWithCategory() {
Result result = new JUnitCore().run(SuiteWithParameterizedTestWithMethodWithCategory.class);
assertEquals(2, result.getRunCount());
assertEquals(0, result.getFailureCount());
}
Aggregations