示例#1
0
文件: TestTest.java 项目: peas/gradle
 @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());
 }
示例#2
0
文件: TestTest.java 项目: peas/gradle
 @org.junit.Test
 public void testExecuteWithTestFailuresAndIgnoreFailures() {
   configureTask();
   test.setIgnoreFailures(true);
   expectTestsFail();
   test.executeTests();
 }
示例#3
0
文件: TestTest.java 项目: peas/gradle
  @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")));
  }
示例#4
0
文件: TestTest.java 项目: peas/gradle
  @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")));
  }
示例#5
0
文件: TestTest.java 项目: peas/gradle
  @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);
  }
示例#6
0
文件: TestTest.java 项目: peas/gradle
  @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);
  }
示例#7
0
文件: TestTest.java 项目: peas/gradle
  @org.junit.Test
  public void testExecute() {
    configureTask();
    expectTestsExecuted();

    test.executeTests();
  }
示例#8
0
文件: TestTest.java 项目: peas/gradle
 @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());
 }
示例#9
0
文件: TestTest.java 项目: peas/gradle
 @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"));
   }
 }
示例#10
0
文件: TestTest.java 项目: peas/gradle
  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());
  }