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.api.report;
20  
21  import javax.annotation.Nonnull;
22  
23  /**
24   * Describes a single entry for a test report.
25   */
26  public interface ReportEntry {
27      /**
28       * The class name of the test.
29       *
30       * @return a string with the class name
31       */
32      String getSourceName();
33  
34      /**
35       * Human readable {@link #getSourceName() test class}.
36       *
37       * @return source text
38       */
39      String getSourceText();
40  
41      /**
42       * The actual qualified Java class name of the test (e.g. including {@code $}-separated nested class names),
43       * independent of any display name. Returns {@code null} when the provider has not set this value, in which case
44       * consumers should fall back to {@link #getSourceText()} / {@link #getSourceName()}.
45       *
46       * @return qualified class name, or {@code null}
47       */
48      default String getSourceQualifiedName() {
49          return null;
50      }
51  
52      /**
53       * The name of the test case.
54       *
55       * @return a string describing the test case
56       */
57      String getName();
58  
59      /**
60       * Human readable {@link #getName() test case}.
61       *
62       * @return name text
63       */
64      String getNameText();
65  
66      /**
67       * The group/category of the testcase.
68       *
69       * @return a string
70       */
71      String getGroup();
72  
73      /**
74       * The group/category of the testcase.
75       *
76       * @return stack trace object
77       */
78      StackTraceWriter getStackTraceWriter();
79  
80      /**
81       * Gets the runtime for the item. Optional parameter. If the value is not set, it will be determined within
82       * the reporting subsystem. Some providers like to calculate this value themselves, and it gets the
83       * most accurate value.
84       *
85       * @return duration of a test in milliseconds
86       */
87      Integer getElapsed();
88  
89      /**
90       * Returns same value as {@link #getElapsed()} and fallbacks to {@code fallback} for <code>null</code> elapsed
91       * timed.
92       *
93       * @param fallback usually 0
94       * @return elapsed time if {@link #getElapsed()} is not null; otherwise returns {@code fallback}
95       */
96      int getElapsed(int fallback);
97  
98      /**
99       * A message relating to a non-successful termination.
100      * May be the "message" from an exception or the reason for a test being ignored.
101      *
102      * @return a string that explains an anomaly
103      */
104     String getMessage();
105 
106     /**
107      * A source name of the test case together with the group or category (if any exists).
108      *
109      * @return a string with the test case name and group/category, or just the name
110      */
111     String getNameWithGroup();
112 
113     /**
114      * A source text of the test case together with the group or category (if any exists).
115      *
116      * @return a string with the test case text and group/category, or just the source text. If no
117      * source text is provided, then this will return null.
118      */
119     String getReportNameWithGroup();
120 
121     /**
122      * Run mode.
123      *
124      * @return a normal run, or re-run
125      */
126     @Nonnull
127     RunMode getRunMode();
128 
129     /**
130      * This represents a reference pointing to a literal representation of test description or literal unique id.
131      *
132      * @return id
133      */
134     Long getTestRunId();
135 }