@org.junit.Test public void testExecuteWithTestFailuresAndIgnoreFailures() { configureTask(); test.setIgnoreFailures(true); expectTestsFail(); test.executeTests(); }
@org.junit.Test public void testExecute() { configureTask(); expectTestsExecuted(); test.executeTests(); }
@org.junit.Test public void testExecuteWithTestFailuresAndStopAtFailures() { configureTask(); expectTestsFail(); try { test.executeTests(); fail(); } catch (GradleException e) { assertThat(e.getMessage(), startsWith("There were failing tests. See the report at")); } }
@org.junit.Test public void generatesReport() { configureTask(); expectTestsExecuted(); final TestReporter testReporter = context.mock(TestReporter.class); test.setTestReporter(testReporter); context.checking( new Expectations() { { one(testReporter) .generateReport(with(any(TestResultsProvider.class)), with(equal(reportDir))); } }); test.executeTests(); }
@org.junit.Test public void testSetsTestFrameworkToNullAfterExecution() { configureTask(); // using a jmock generated mock for testFramework does not work here as it is referenced // by jmock holds some references. test.useTestFramework( new TestFramework() { public TestFrameworkDetector getDetector() { return null; } public TestFrameworkOptions getOptions() { return null; } public WorkerTestClassProcessorFactory getProcessorFactory() { return null; } public org.gradle.api.Action<WorkerProcessBuilder> getWorkerConfigurationAction() { return null; } }); context.checking( new Expectations() { { one(testExecuterMock) .execute(with(sameInstance(test)), with(notNullValue(TestListenerAdapter.class))); } }); WeakReference<TestFramework> weakRef = new WeakReference<TestFramework>(test.getTestFramework()); test.executeTests(); System.gc(); // explicit gc should normally be avoided, but necessary here. assertNull(weakRef.get()); }