Example #1
0
 @org.junit.Test
 public void testExecuteWithTestFailuresAndIgnoreFailures() {
   configureTask();
   test.setIgnoreFailures(true);
   expectTestsFail();
   test.executeTests();
 }
Example #2
0
  @org.junit.Test
  public void testExecute() {
    configureTask();
    expectTestsExecuted();

    test.executeTests();
  }
Example #3
0
 @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"));
   }
 }
Example #4
0
  @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();
  }
Example #5
0
  @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());
  }