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

    test.executeTests();
  }
Ejemplo n.º 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"));
   }
 }
Ejemplo n.º 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();
  }
Ejemplo n.º 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());
  }