View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.surefire.its.jiras;
20  
21  import java.util.List;
22  
23  import org.apache.maven.plugins.surefire.report.ReportTestSuite;
24  import org.apache.maven.surefire.its.fixture.OutputValidator;
25  import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
26  import org.junit.Test;
27  
28  import static org.apache.maven.surefire.its.fixture.HelperAssertions.extractReports;
29  import static org.hamcrest.MatcherAssert.assertThat;
30  import static org.hamcrest.Matchers.greaterThanOrEqualTo;
31  import static org.hamcrest.Matchers.hasSize;
32  import static org.hamcrest.Matchers.is;
33  
34  /**
35   * Test that runtime reported on console matches runtime in XML
36   *
37   * @author <a href="mailto:eloussi2@illinois.edu">Lamyaa Eloussi</a>
38   */
39  @SuppressWarnings("checkstyle:magicnumber")
40  public class Surefire1144XmlRunTimeIT extends SurefireJUnit4IntegrationTestCase {
41      @Test
42      public void testXmlRunTime() {
43          OutputValidator outputValidator =
44                  unpack("/surefire-1144-xml-runtime").forkOnce().executeTest();
45  
46          List<ReportTestSuite> reports = extractReports(outputValidator.getBaseDir());
47          assertThat(reports, hasSize(1));
48  
49          ReportTestSuite report = reports.get(0);
50          float xmlTime = report.getTimeElapsed();
51  
52          assertThat(xmlTime, is(greaterThanOrEqualTo(1.6f))); // include beforeClass and afterClass
53          outputValidator.verifyTextInLog(Float.toString(xmlTime)); // same time in console
54      }
55  }