InjectBundle.java revision fc37a0172db7197e6e0702dfa9bfdd6bed1947b1
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 */
16package com.android.test;
17
18import android.os.Bundle;
19
20import junit.framework.Test;
21
22import org.junit.Before;
23
24import java.lang.annotation.ElementType;
25import java.lang.annotation.Retention;
26import java.lang.annotation.RetentionPolicy;
27import 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 *     &#64;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 */
42@Retention(RetentionPolicy.RUNTIME)
43@Target(ElementType.FIELD)
44public @interface InjectBundle {
45
46}
47