• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 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 
17 package com.android.ddmlib.testrunner;
18 
19 /**
20  * Receives event notifications during instrumentation test runs.
21  * Patterned after {@link junit.runner.TestRunListener}.
22  */
23 public interface ITestRunListener {
24 
25     /**
26      *  Types of test failures.
27      */
28     enum TestFailure {
29         /** Test failed due to unanticipated uncaught exception. */
30         ERROR,
31         /** Test failed due to a false assertion. */
32         FAILURE
33     }
34 
35     /**
36      * Reports the start of a test run.
37      *
38      * @param testCount total number of tests in test run
39      */
testRunStarted(int testCount)40     public void testRunStarted(int testCount);
41 
42     /**
43      * Reports end of test run.
44      *
45      * @param elapsedTime device reported elapsed time, in milliseconds
46      */
testRunEnded(long elapsedTime)47     public void testRunEnded(long elapsedTime);
48 
49     /**
50      * Reports test run stopped before completion.
51      *
52      * @param elapsedTime device reported elapsed time, in milliseconds
53      */
testRunStopped(long elapsedTime)54     public void testRunStopped(long elapsedTime);
55 
56     /**
57      * Reports the start of an individual test case.
58      *
59      * @param test identifies the test
60      */
testStarted(TestIdentifier test)61     public void testStarted(TestIdentifier test);
62 
63     /**
64      * Reports the execution end of an individual test case.
65      * If {@link #testFailed} was not invoked, this test passed.
66      *
67      * @param test identifies the test
68      */
testEnded(TestIdentifier test)69     public void testEnded(TestIdentifier test);
70 
71     /**
72      * Reports the failure of a individual test case.
73      * Will be called between testStarted and testEnded.
74      *
75      * @param status failure type
76      * @param test identifies the test
77      * @param trace stack trace of failure
78      */
testFailed(TestFailure status, TestIdentifier test, String trace)79     public void testFailed(TestFailure status, TestIdentifier test, String trace);
80 
81     /**
82      * Reports test run failed to execute due to a fatal error.
83      */
testRunFailed(String errorMessage)84     public void testRunFailed(String errorMessage);
85 }
86