1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package org.chromium.base.test.params; 6 7 import java.lang.annotation.ElementType; 8 import java.lang.annotation.Retention; 9 import java.lang.annotation.RetentionPolicy; 10 import java.lang.annotation.Target; 11 12 /** 13 * Annotations for Parameterized Tests 14 */ 15 public class ParameterAnnotations { 16 /** 17 * Annotation for test methods to indicate associated {@link ParameterProvider}. 18 * Note: the class referred to must be public and have a public default constructor. 19 */ 20 @Retention(RetentionPolicy.RUNTIME) 21 @Target(ElementType.METHOD) 22 public @interface UseMethodParameter { value()23 Class<? extends ParameterProvider> value(); 24 } 25 26 /** 27 * Annotation for methods that should be called before running a test with method parameters. 28 * 29 * In order to use this, add a {@link MethodParamAnnotationRule} annotated with 30 * {@code @}{@link org.junit.Rule Rule} to your test class. 31 * @see ParameterProvider 32 * @see UseMethodParameterAfter 33 */ 34 @Retention(RetentionPolicy.RUNTIME) 35 @Target(ElementType.METHOD) 36 public @interface UseMethodParameterBefore { value()37 Class<? extends ParameterProvider> value(); 38 } 39 40 /** 41 * Annotation for methods that should be called after running a test with method parameters. 42 * 43 * In order to use this, add a {@link MethodParamAnnotationRule} annotated with 44 * {@code @}{@link org.junit.Rule Rule} to your test class. 45 * @see ParameterProvider 46 * @see UseMethodParameterBefore 47 */ 48 @Retention(RetentionPolicy.RUNTIME) 49 @Target(ElementType.METHOD) 50 public @interface UseMethodParameterAfter { value()51 Class<? extends ParameterProvider> value(); 52 } 53 54 /** 55 * Annotation for static field of a `List<ParameterSet>` for entire test class 56 */ 57 @Retention(RetentionPolicy.RUNTIME) 58 @Target(ElementType.FIELD) 59 public @interface ClassParameter {} 60 61 /** 62 * Annotation for static field of a `List<ParameterSet>` of TestRule 63 */ 64 @Retention(RetentionPolicy.RUNTIME) 65 @Target(ElementType.FIELD) 66 public @interface RuleParameter {} 67 68 /** 69 * Annotation for test class, it specifies which ParameterizeRunnerDelegate to use. 70 * 71 * The default ParameterizedRunnerDelegate is BaseJUnit4RunnerDelegate.class 72 */ 73 @Retention(RetentionPolicy.RUNTIME) 74 @Target(ElementType.TYPE) 75 public @interface UseRunnerDelegate { value()76 Class<? extends ParameterizedRunnerDelegate> value(); 77 } 78 } 79