Example #1
0
 @org.junit.Test
 public void testExcludes() {
   assertSame(test, test.exclude(TEST_PATTERN_1, TEST_PATTERN_2));
   assertEquals(toLinkedSet(TEST_PATTERN_1, TEST_PATTERN_2), test.getExcludes());
   test.exclude(TEST_PATTERN_3);
   assertEquals(toLinkedSet(TEST_PATTERN_1, TEST_PATTERN_2, TEST_PATTERN_3), test.getExcludes());
 }
Example #2
0
 @org.junit.Test
 public void testExecuteWithTestFailuresAndIgnoreFailures() {
   configureTask();
   test.setIgnoreFailures(true);
   expectTestsFail();
   test.executeTests();
 }
Example #3
0
  @org.junit.Test
  public void testAddsDefaultIncludeAndExcludePatternsWhenTestScanningIsOff() {
    configureTask();
    test.setScanForTestClasses(false);

    ConfigurableFileTree files = (ConfigurableFileTree) test.getCandidateClassFiles();
    assertThat(files.getDir(), equalTo(classesDir));
    assertThat(files.getIncludes(), equalTo(toSet("**/*Tests.class", "**/*Test.class")));
    assertThat(files.getExcludes(), equalTo(toSet("**/Abstract*.class")));
  }
Example #4
0
  @org.junit.Test
  public void testScansForTestClassesInTheTestClassesDir() {
    configureTask();
    test.include("include");
    test.exclude("exclude");

    FileTree classFiles = test.getCandidateClassFiles();
    assertThat(classFiles, instanceOf(ConfigurableFileTree.class));
    ConfigurableFileTree files = (ConfigurableFileTree) classFiles;
    assertThat(files.getDir(), equalTo(classesDir));
    assertThat(files.getIncludes(), equalTo(toSet("include")));
    assertThat(files.getExcludes(), equalTo(toSet("exclude")));
  }
Example #5
0
  @org.junit.Test
  public void notifiesListenerBeforeTest() {
    final TestClosure closure = context.mock(TestClosure.class);
    test.beforeTest(HelperUtil.toClosure(closure));

    final TestDescriptor testDescriptor = context.mock(TestDescriptor.class);

    context.checking(
        new Expectations() {
          {
            one(closure).call(testDescriptor);
          }
        });

    test.getTestListenerBroadcaster().getSource().beforeTest(testDescriptor);
  }
Example #6
0
  @org.junit.Test
  public void notifiesListenerOfEvents() {
    final TestListener listener = context.mock(TestListener.class);
    test.addTestListener(listener);

    final TestDescriptor testDescriptor = context.mock(TestDescriptor.class);

    context.checking(
        new Expectations() {
          {
            one(listener).beforeSuite(testDescriptor);
          }
        });

    test.getTestListenerBroadcaster().getSource().beforeSuite(testDescriptor);
  }
Example #7
0
  @org.junit.Test
  public void testExecute() {
    configureTask();
    expectTestsExecuted();

    test.executeTests();
  }
Example #8
0
 @org.junit.Test
 public void testInit() {
   assertThat(test.getTestFramework(), instanceOf(JUnitTestFramework.class));
   assertNull(test.getTestClassesDir());
   assertNull(test.getClasspath());
   assertNull(test.getTestResultsDir());
   assertNull(test.getTestReportDir());
   assertThat(test.getIncludes(), isEmpty());
   assertThat(test.getExcludes(), isEmpty());
   assertFalse(test.isIgnoreFailures());
 }
Example #9
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 #10
0
  private void configureTask() {
    test.useTestFramework(testFrameworkMock);
    test.setTestExecuter(testExecuterMock);

    test.setTestClassesDir(classesDir);
    test.setTestResultsDir(resultsDir);
    test.setTestReportDir(reportDir);
    test.setClasspath(classpathMock);
    test.setTestSrcDirs(Collections.<File>emptyList());
  }