コード例 #1
0
ファイル: TestOutcomes.java プロジェクト: kpiwko/thucydides
 /** @return The total duration of all of the tests in this set in milliseconds. */
 public Long getDuration() {
   Long total = 0L;
   for (TestOutcome outcome : outcomes) {
     total += outcome.getDuration();
   }
   return total;
 }
コード例 #2
0
 @Test
 public void we_can_record_the_lifetime_of_a_test_run() throws InterruptedException {
   Thread.sleep(10);
   testOutcome.recordDuration();
   assertThat(testOutcome.getDuration(), is(greaterThanOrEqualTo(10L)));
   assertThat(testOutcome.getDuration(), is(lessThan(1000L)));
 }
  private void recordTestOutcomeAsSteps(TestOutcome testOutcome, TestOutcome scenarioOutcome) {
    final String name = alternativeMethodName(testOutcome);
    TestStep nestedStep = TestStep.forStepCalled(name).withResult(testOutcome.getResult());
    List<TestStep> testSteps = testOutcome.getTestSteps();

    if (testOutcome.getTestFailureCause() != null) {
      nestedStep.failedWith(testOutcome.getTestFailureCause().toException());
    }

    if (!testSteps.isEmpty()) {
      for (TestStep nextStep : testSteps) {
        nextStep.setDescription(
            normalizeTestStepDescription(
                nextStep.getDescription(), scenarioOutcome.getTestSteps().size() + 1));
        nestedStep.addChildStep(nextStep);
        nestedStep.setDuration(nextStep.getDuration() + nestedStep.getDuration());
      }
    }

    if (nestedStep.getDuration() == 0) {
      nestedStep.setDuration(testOutcome.getDuration());
    }
    scenarioOutcome.recordStep(nestedStep);
  }