public void testExecuteWithUnspecifiedTestResultsDir() { setUpMocks(test); test.setTestResultsDir(null); try { test.execute(); fail(); } catch (Exception e) { assertThat(e.getCause(), Matchers.instanceOf(InvalidUserDataException.class)); } }
@org.junit.Test public void testExecuteWithNonExistingCompiledTestsDir() { setUpMocks(test); test.setUnmanagedClasspath(null); context.checking( new Expectations() { { allowing(existentDirsFilterMock) .checkExistenceAndThrowStopActionIfNot(TEST_TEST_CLASSES_DIR); will(throwException(new StopActionException())); } }); test.existingDirsFilter = existentDirsFilterMock; test.execute(); }
@org.junit.Test(expected = GradleException.class) public void testExecuteWithTestFailuresAndStopAtFailures() { setUpMocks(test); setExistingDirsFilter(); context.checking( new Expectations() { { one(testFrameworkMock).prepare(getProject(), test); one(testFrameworkMock).getTestClassNames(); will(returnValue(okTestClassNames)); one(testFrameworkMock) .execute(getProject(), test, okTestClassNames, new ArrayList<String>()); } }); test.execute(); }
@org.junit.Test public void testExecuteWithTestFailuresAndContinueWithFailures() { setUpMocks(test); setExistingDirsFilter(); test.setStopAtFailuresOrErrors(false); context.checking( new Expectations() { { one(testFrameworkMock).prepare(getProject(), test); one(testFrameworkMock).getTestClassNames(); will(returnValue(okTestClassNames)); one(testFrameworkMock) .execute(getProject(), test, okTestClassNames, new ArrayList<String>()); one(testFrameworkMock).report(getProject(), test); } }); test.execute(); }