1 /* 2 * Copyright (C) 2013 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.test; 17 18 import android.os.Bundle; 19 20 import junit.framework.Test; 21 22 import org.junit.Before; 23 24 import java.lang.annotation.ElementType; 25 import java.lang.annotation.Retention; 26 import java.lang.annotation.RetentionPolicy; 27 import java.lang.annotation.Target; 28 29 /** 30 * Use this to inject a {@link Bundle} containing the command line arguments passed to the 31 * test runner into your JUnit4-style test. 32 * <p/> 33 * To use, just add the correct annotation to an {@link Bundle} field like this: 34 * <pre> 35 * @InjectBundle public Bundle mMyBundle; 36 * </pre> 37 * The test runner will set the value of this field with the {@link Bundle} after 38 * object construction but before any {@link Before} methods are called. 39 * <p/> 40 * Declaring this in a JUnit3 test (ie a class that is a {@link Test}) will have no effect. 41 * Use {@link BundleTest} instead. 42 */ 43 @Retention(RetentionPolicy.RUNTIME) 44 @Target(ElementType.FIELD) 45 public @interface InjectBundle { 46 47 } 48