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 name of the test case.
43       *
44       * @return a string describing the test case
45       */
46      String getName();
47  
48      /**
49       * Human readable {@link #getName() test case}.
50       *
51       * @return name text
52       */
53      String getNameText();
54  
55      /**
56       * The group/category of the testcase.
57       *
58       * @return a string
59       */
60      String getGroup();
61  
62      /**
63       * The group/category of the testcase.
64       *
65       * @return stack trace object
66       */
67      StackTraceWriter getStackTraceWriter();
68  
69      /**
70       * Gets the runtime for the item. Optional parameter. If the value is not set, it will be determined within
71       * the reporting subsystem. Some providers like to calculate this value themselves, and it gets the
72       * most accurate value.
73       *
74       * @return duration of a test in milliseconds
75       */
76      Integer getElapsed();
77  
78      /**
79       * Returns same value as {@link #getElapsed()} and fallbacks to {@code fallback} for <code>null</code> elapsed
80       * timed.
81       *
82       * @param fallback usually 0
83       * @return elapsed time if {@link #getElapsed()} is not null; otherwise returns {@code fallback}
84       */
85      int getElapsed(int fallback);
86  
87      /**
88       * A message relating to a non-successful termination.
89       * May be the "message" from an exception or the reason for a test being ignored.
90       *
91       * @return a string that explains an anomaly
92       */
93      String getMessage();
94  
95      /**
96       * A source name of the test case together with the group or category (if any exists).
97       *
98       * @return a string with the test case name and group/category, or just the name
99       */
100     String getNameWithGroup();
101 
102     /**
103      * A source text of the test case together with the group or category (if any exists).
104      *
105      * @return a string with the test case text and group/category, or just the source text. If no
106      * source text is provided, then this will return null.
107      */
108     String getReportNameWithGroup();
109 
110     /**
111      * Run mode.
112      *
113      * @return a normal run, or re-run
114      */
115     @Nonnull
116     RunMode getRunMode();
117 
118     /**
119      * This represents a reference pointing to a literal representation of test description or literal unique id.
120      *
121      * @return id
122      */
123     Long getTestRunId();
124 }