コード例 #1
0
ファイル: TestTest.java プロジェクト: baiyanhuang/backup
 @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"));
   }
 }
コード例 #2
0
 public ExecutionFailure assertThatCause(final Matcher<String> matcher) {
   if (failure instanceof LocationAwareException) {
     LocationAwareException exception = (LocationAwareException) failure;
     assertThat(exception.getReportableCauses(), hasItem(hasMessage(matcher)));
   } else {
     assertThat(failure.getCause(), notNullValue());
     assertThat(failure.getCause().getMessage(), matcher);
   }
   return this;
 }
コード例 #3
0
 public ExecutionFailure assertHasNoCause() {
   if (failure instanceof LocationAwareException) {
     LocationAwareException exception = (LocationAwareException) failure;
     assertThat(exception.getReportableCauses(), isEmpty());
   } else {
     assertThat(failure.getCause(), nullValue());
   }
   outputFailure.assertHasNoCause();
   return this;
 }
コード例 #4
0
    public InProcessExecutionFailure(
        List<String> tasks,
        Set<String> skippedTasks,
        OutputScrapingExecutionFailure outputFailure,
        GradleException failure) {
      super(tasks, skippedTasks, outputFailure);
      this.outputFailure = outputFailure;
      this.failure = failure;

      // Chop up the exception message into its expected parts
      java.util.regex.Matcher matcher = LOCATION_PATTERN.matcher(failure.getMessage());
      if (matcher.find()) {
        fileName = matcher.group(1);
        lineNumber = matcher.group(3);
        description = failure.getMessage().substring(matcher.end()).trim();
      } else {
        fileName = "";
        lineNumber = "";
        description = failure.getMessage().trim();
      }
    }
コード例 #5
0
  @Test
  public void wrapsOnlyIfPredicateFailure() {
    final Throwable failure = new RuntimeException();
    final Collector<Throwable> wrappedFailure = collector();
    context.checking(
        new Expectations() {
          {
            allowing(task).getEnabled();
            will(returnValue(true));
            one(spec).isSatisfiedBy(task);
            will(throwException(failure));
            one(state).executed(with(notNullValue(GradleException.class)));
            will(collectTo(wrappedFailure));
          }
        });

    executer.execute(task, state, executionContext);

    GradleException exception = (GradleException) wrappedFailure.get();
    assertThat(exception.getMessage(), equalTo("Could not evaluate onlyIf predicate for <task>."));
    assertThat(exception.getCause(), sameInstance(failure));
  }
コード例 #6
0
 public ExecutionFailure assertThatDescription(Matcher<String> matcher) {
   assertThat(failure.getMessage(), containsLine(matcher));
   return this;
 }
コード例 #7
0
 public ExecutionFailure assertHasFileName(String filename) {
   assertThat(failure.getMessage(), startsWith(String.format("%s", filename)));
   return this;
 }
コード例 #8
0
 public ExecutionFailure assertHasLineNumber(int lineNumber) {
   assertThat(failure.getMessage(), containsString(String.format(" line: %d", lineNumber)));
   return this;
 }