| 1 |
package org.jmock.junit5.acceptance; |
| 2 |
|
| 3 |
import org.jmock.junit5.testdata.jmock.acceptance.DerivedJUnit5TestThatDoesNotSatisfyExpectations; |
| 4 |
import org.jmock.junit5.testdata.jmock.acceptance.JUnit5TestThatAutoInstantiatesMocks; |
| 5 |
import org.jmock.junit5.testdata.jmock.acceptance.JUnit5TestThatCreatesNoMockery; |
| 6 |
import org.jmock.junit5.testdata.jmock.acceptance.JUnit5TestThatCreatesTwoMockeries; |
| 7 |
import org.jmock.junit5.testdata.jmock.acceptance.JUnit5TestThatDoesNotCreateAMockery; |
| 8 |
import org.jmock.junit5.testdata.jmock.acceptance.JUnit5TestThatDoesNotSatisfyExpectations; |
| 9 |
import org.jmock.junit5.testdata.jmock.acceptance.JUnit5TestThatDoesSatisfyExpectations; |
| 10 |
import org.jmock.junit5.testdata.jmock.acceptance.JUnit5TestThatThrowsExpectedException; |
| 11 |
import org.junit.jupiter.api.Test; |
| 12 |
|
| 13 |
/** |
| 14 |
* Wrap, running "testdata" testcases. Some of which are supposed to fail |
| 15 |
* @author oliverbye |
| 16 |
* |
| 17 |
*/ |
| 18 |
public class JUnit5TestRunnerTests { |
| 19 |
|
| 20 |
FailureRecordingTestExecutionListener listener = new FailureRecordingTestExecutionListener(); |
| 21 |
|
| 22 |
@Test |
| 23 |
public void testTheJUnit5TestRunnerReportsPassingTestsAsSuccessful() { |
| 24 |
listener.runTestIn(JUnit5TestThatDoesSatisfyExpectations.class); |
| 25 |
listener.assertTestSucceeded(); |
| 26 |
} |
| 27 |
|
| 28 |
@Test |
| 29 |
public void testTheJUnit5TestRunnerAutomaticallyAssertsThatAllExpectationsHaveBeenSatisfied() { |
| 30 |
listener.runTestIn(JUnit5TestThatDoesNotSatisfyExpectations.class); |
| 31 |
listener.assertTestFailedWith(AssertionError.class); |
| 32 |
} |
| 33 |
|
| 34 |
@Test |
| 35 |
public void testTheJUnit5TestRunnerLooksForTheMockeryInBaseClasses() { |
| 36 |
listener.runTestIn(DerivedJUnit5TestThatDoesNotSatisfyExpectations.class); |
| 37 |
listener.assertTestFailedWith(AssertionError.class); |
| 38 |
} |
| 39 |
|
| 40 |
@Test |
| 41 |
public void testTheJUnit5TestRunnerReportsAHelpfulErrorIfTheMockeryIsNull() { |
| 42 |
listener.runTestIn(JUnit5TestThatDoesNotCreateAMockery.class); |
| 43 |
listener.assertTestFailedWith(org.junit.platform.commons.util.PreconditionViolationException.class); |
| 44 |
} |
| 45 |
|
| 46 |
// See issue JMOCK-156 |
| 47 |
@Test |
| 48 |
public void testReportsMocksAreNotSatisfiedWhenExpectedExceptionIsThrown() { |
| 49 |
listener.runTestIn(JUnit5TestThatThrowsExpectedException.class); |
| 50 |
listener.assertTestFailedWith(AssertionError.class); |
| 51 |
} |
| 52 |
|
| 53 |
// See issue JMOCK-219 |
| 54 |
@Test |
| 55 |
public void testTheJUnit5TestRunnerReportsIfNoMockeryIsFound() { |
| 56 |
listener.runTestIn(JUnit5TestThatCreatesNoMockery.class); |
| 57 |
listener.assertTestFailedWithInitializationError(); |
| 58 |
} |
| 59 |
|
| 60 |
// See issue JMOCK-219 |
| 61 |
@Test |
| 62 |
public void testTheJUnit4TestRunnerReportsIfMoreThanOneMockeryIsFound() { |
| 63 |
listener.runTestIn(JUnit5TestThatCreatesTwoMockeries.class); |
| 64 |
listener.assertTestFailedWithInitializationError(); |
| 65 |
} |
| 66 |
|
| 67 |
@Test |
| 68 |
public void testAutoInstantiatesMocks() { |
| 69 |
listener.runTestIn(JUnit5TestThatAutoInstantiatesMocks.class); |
| 70 |
listener.assertTestSucceeded(); |
| 71 |
} |
| 72 |
} |