1 /*
2  * Copyright (C) 2010 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.tradefed.testtype;
17 
18 import com.android.tradefed.device.DeviceNotAvailableException;
19 import com.android.tradefed.invoker.TestInformation;
20 import com.android.tradefed.result.ITestInvocationListener;
21 
22 /**
23  * A test that reports results directly to a {@link ITestInvocationListener}.
24  *
25  * <p>This has the following benefits over a JUnit.
26  *
27  * <ul>
28  *   <li> easier to report the results of a test that has been run remotely on an Android device, as
29  *       the results of a remote test don't need to be unnecessarily marshalled and unmarshalled
30  *       from JUnit Test objects.
31  *   <li> supports reporting test metrics
32  * </ul>
33  */
34 public interface IRemoteTest {
35 
36     /**
37      * Runs the tests, and reports result to the listener.
38      *
39      * @param listener the {@link ITestInvocationListener} of test results
40      * @throws DeviceNotAvailableException
41      * @deprecated Use {@link #run(TestInformation, ITestInvocationListener)} instead.
42      */
43     @Deprecated
run(ITestInvocationListener listener)44     public default void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
45         // Throw if not implemented: If the new interface is implemented this won't be called. If
46         // something is calling the old interface instead of new one, then it will throw and report
47         // the error.
48         throw new UnsupportedOperationException(
49                 "run(ITestInvocationListener) is deprecated. You need to update to the new "
50                         + "run(TestInformation, ITestInvocationListener) interface.");
51     }
52 
53     /**
54      * Runs the tests, and reports result to the listener.
55      *
56      * @param testInfo The {@link TestInformation} object containing useful information to run
57      *     tests.
58      * @param listener the {@link ITestInvocationListener} of test results
59      * @throws DeviceNotAvailableException
60      */
run(TestInformation testInfo, ITestInvocationListener listener)61     public default void run(TestInformation testInfo, ITestInvocationListener listener)
62             throws DeviceNotAvailableException {
63         run(listener);
64     }
65 }
66