1 /*
2  * Copyright (C) 2023 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 platform.test.runner.parameterized;
18 
19 import java.lang.annotation.ElementType;
20 import java.lang.annotation.Retention;
21 import java.lang.annotation.RetentionPolicy;
22 import java.lang.annotation.Target;
23 import java.text.MessageFormat;
24 
25 /**
26  * Annotation for a method which provides parameters to be injected into the test class constructor
27  * by {@code ParameterizedAndroidJunit4}.
28  *
29  * <p>{@see org.junit.runners.Parameterized.Parameters}
30  */
31 @Retention(RetentionPolicy.RUNTIME)
32 @Target(ElementType.METHOD)
33 public @interface Parameters {
34 
35     /**
36      * Optional pattern to derive the test's name from the parameters. Use numbers in braces to
37      * refer to the parameters or the additional data as follows:
38      *
39      * <pre>
40      * {index} - the current parameter index
41      * {0} - the first parameter value
42      * {1} - the second parameter value
43      * etc...
44      * </pre>
45      *
46      * <p>Default value is "{index}" for compatibility with previous JUnit versions.
47      *
48      * @return {@link MessageFormat} pattern string, except the index placeholder.
49      * @see MessageFormat
50      */
name()51     String name() default "{index}";
52 
53     /**
54      * Specifies the test environment this parameter provider should be used. A test can define
55      * multiple methods as Parameters provider. The runner will first try to pick the most specific
56      * provider, and fallback to the default provider if there is none.
57      */
target()58     TestEnvironment target() default TestEnvironment.ALL;
59 
60     enum TestEnvironment {
61         ALL,
62         DEVICE,
63         DEVICE_LESS
64     }
65 }
66