Annotation Type InjectBundleContext


@Inherited @Target({FIELD,PARAMETER}) @Retention(RUNTIME) @ExtendWith(BundleContextExtension.class) @Documented public @interface InjectBundleContext
Inject BundleContext into test classes and methods.

The BundleContext implementation provided by this rule will automatically clean up all service registrations, bundle, service and framework listeners, as well as installed bundles left behind.

Example:

 // For JUnit5
 @ExtendWith(BundleContextExtension.class)
 class MyTests {
        // For JUnit4
        @Rule
        BundleContextRule bcr = new BundleContextRule();

        @InjectBundleContext
        BundleContext bundleContext;

        @Test
        public void test() {
                // use bundleContext
        }
 }