1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.compatibility.common.util;
17 
18 import java.util.List;
19 
20 /**
21  * Represents a single test result.
22  */
23 public interface ITestResult extends Comparable<ITestResult> {
24 
25     /**
26      * @return The name of this test result.
27      */
getName()28     String getName();
29 
30     /**
31      * @return The full name of this test result, ie
32      * &lt;package-name&gt;.&lt;class-name&gt;#&lt;method-name&gt;
33      */
getFullName()34     String getFullName();
35 
36     /**
37      * @return The {@link TestStatus} of this result.
38      */
getResultStatus()39     TestStatus getResultStatus();
40 
41     /**
42      * Sets the {@link TestStatus} of the result and updates the end time of the test.
43      *
44      * @param status The {@link TestStatus} of this result.
45      */
setResultStatus(TestStatus status)46     void setResultStatus(TestStatus status);
47 
48     /**
49      * @return The failure message to display
50      */
getMessage()51     String getMessage();
52 
53     /**
54      * @param message The message to display which describes the failure
55      */
setMessage(String message)56     void setMessage(String message);
57 
58     /**
59      * @return The stack trace generated by the failure
60      */
getStackTrace()61     String getStackTrace();
62 
63     /**
64      * @param stackTrace the stack trace generated by the failure.
65      */
setStackTrace(String stackTrace)66     void setStackTrace(String stackTrace);
67 
68     /**
69      * @return the metrics report.
70      */
getReportLog()71     ReportLog getReportLog();
72 
73     /**
74      * @param report the metrics report.
75      */
setReportLog(ReportLog report)76     void setReportLog(ReportLog report);
77 
78     /**
79      * @return the path of the bug report generated of the failure.
80      */
getBugReport()81     String getBugReport();
82 
83     /**
84      * @param path the path of the bug report generated of the failure.
85      */
setBugReport(String path)86     void setBugReport(String path);
87 
88     /**
89      * @return the path of the log file generated of the failure.
90      */
getLog()91     String getLog();
92 
93     /**
94      * @param path the path of the log file generated of the failure.
95      */
setLog(String path)96     void setLog(String path);
97 
98     /**
99      * @return the path of the screenshot file generated of the failure.
100      */
getScreenshot()101     String getScreenshot();
102 
103     /**
104      * @param path the path of the screenshot file generated of the failure.
105      */
setScreenshot(String path)106     void setScreenshot(String path);
107 
108     /**
109      * Report the test as a failure.
110      *
111      * @param trace the stacktrace of the failure.
112      */
failed(String trace)113     void failed(String trace);
114 
115     /**
116      * Report that the test has completed.
117      *
118      * @param report A report generated by the test, or null.
119      */
passed(ReportLog report)120     void passed(ReportLog report);
121 
122     /**
123      * Report that the test was skipped.
124      *
125      * This means that the test is not considered appropriate for the
126      * current device, and thus is never attempted. The test does not require execution,
127      * and nothing more needs to be done.
128      */
skipped()129     void skipped();
130 
131     /**
132      * Retrieves whether execution for this test result has been determined unnecessary.
133      */
isSkipped()134     boolean isSkipped();
135 
136     /**
137      * Resets the result.
138      */
reset()139     void reset();
140 
141     /**
142      * Sets whether the test result status has been generated from a previous testing session.
143      */
setRetry(boolean isRetry)144     void setRetry(boolean isRetry);
145 
146     /**
147      * Retrieves whether the test result status has been generated from a previous testing session.
148      */
isRetry()149     boolean isRetry();
150 
151     /**
152      * Clear the existing result and default to 'failed'
153      */
removeResult()154     void removeResult();
155 
156     /**
157      * This method is to record per-case history for CTS Verifier. If this field is used for large
158      * test suites like CTS, it may cause performance issues in APFE. Thus please do not use this
159      * field in other test suites.
160      *
161      * @return The test result histories
162      */
getTestResultHistories()163     List<TestResultHistory> getTestResultHistories();
164 
165     /**
166      * Set test result histories of test item. This method is for per-case history in CTS Verifier.
167      * If this field is used for large test suites like CTS, it may cause performance issues in
168      * APFE. Thus please do not use this field in other test suites.
169      *
170      * @param resultHistories The test result histories.
171      */
setTestResultHistories(List<TestResultHistory> resultHistories)172     void setTestResultHistories(List<TestResultHistory> resultHistories);
173 }
174