Repository: weld/weld-junit
Pull request #49 (2018-06-08 13:24:27)

Minor updates in code, enhancing javadoc, updating README.

manovotn: Looking at it now, I wonder why we made `AddEnabledInterceptors` and `AddEnabledDecorators` only register the components.
Because then you still need to do `@AddBeanClasses` to add the interceptor to the deployment.

We could either add it automatically (which I would prefer as you hardly ever enable interceptor without having it on classpath, right?) or have an optional attribute on the annotation. @mkouba WDYT, am I missing something?
manovotn: Actually, nevermind, it is a bug. The javadoc of those annotations even says it should be added. I'll fix that.

Patch:
diff --git a/junit-common/src/main/java/org/jboss/weld/junit/AbstractWeldInitiator.java b/junit-common/src/main/java/org/jboss/weld/junit/AbstractWeldInitiator.java
index 47ff5b8..cea050a 100644
--- a/junit-common/src/main/java/org/jboss/weld/junit/AbstractWeldInitiator.java
+++ b/junit-common/src/main/java/org/jboss/weld/junit/AbstractWeldInitiator.java
@@ -316,7 +316,8 @@ public abstract class AbstractWeldInitiator implements Instance<Object>, Contain
         }
 
         /**
-         * Activate and deactivate contexts for the given normal scopes for each test method execution.
+         * Activate and deactivate contexts for the given normal scopes for the lifetime of the initialized Weld container, by default for each test method
+         * execution.
          * <p>
          * {@link ApplicationScoped} is ignored as it is always active.
          * </p>
diff --git a/junit-common/src/main/java/org/jboss/weld/junit/ContextImpl.java b/junit-common/src/main/java/org/jboss/weld/junit/ContextImpl.java
index 94dfb9d..229d98a 100644
--- a/junit-common/src/main/java/org/jboss/weld/junit/ContextImpl.java
+++ b/junit-common/src/main/java/org/jboss/weld/junit/ContextImpl.java
@@ -19,11 +19,13 @@ package org.jboss.weld.junit;
 import java.lang.annotation.Annotation;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.logging.Logger;
 
 import javax.enterprise.context.ContextNotActiveException;
 import javax.enterprise.context.spi.Context;
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.BeanManager;
 
 /**
  *
@@ -31,13 +33,18 @@ import javax.enterprise.context.spi.CreationalContext;
  */
 class ContextImpl implements Context {
 
+    private static final Logger LOGGER = Logger.getLogger(ContextImpl.class.getName());
+
     private final Class<? extends Annotation> scope;
 
+    private final BeanManager beanManager;
+
     // It's a normal scope so there may be no more than one mapped instance per contextual type per thread
     private final ThreadLocal<Map<Contextual<?>, ContextualInstance<?>>> currentContext = new ThreadLocal<>();
 
-    public ContextImpl(Class<? extends Annotation> scope) {
+    ContextImpl(Class<? extends Annotation> scope, BeanManager beanManager) {
         this.scope = scope;
+        this.beanManager = beanManager;
     }
 
     public Class<? extends Annotation> getScope() {
@@ -81,6 +88,7 @@ class ContextImpl implements Context {
 
     public void activate() {
         currentContext.set(new HashMap<Contextual<?>, ContextualInstance<?>>());
+        beanManager.fireEvent(new Object(), InitializedLiteral.of(scope));
     }
 
     public void deactivate() {
@@ -92,11 +100,12 @@ class ContextImpl implements Context {
             try {
                 instance.destroy();
             } catch (Exception e) {
-                // LOGGER.warning("Unable to destroy instance" + instance.get() + " for bean: " + instance.getContextual());
+                LOGGER.warning("Unable to destroy instance" + instance.get() + " for bean: " + instance.getContextual());
             }
         }
         ctx.clear();
         currentContext.remove();
+        beanManager.fireEvent(new Object(), DestroyedLiteral.of(scope));
     }
 
     /**
diff --git a/junit-common/src/main/java/org/jboss/weld/junit/DestroyedLiteral.java b/junit-common/src/main/java/org/jboss/weld/junit/DestroyedLiteral.java
new file mode 100644
index 0000000..a3fddc7
--- /dev/null
+++ b/junit-common/src/main/java/org/jboss/weld/junit/DestroyedLiteral.java
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit;
+
+import java.lang.annotation.Annotation;
+
+import javax.enterprise.context.Destroyed;
+import javax.enterprise.util.AnnotationLiteral;
+
+/**
+ * Supports inline instantiation of the {@link Destroyed} qualifier.
+ *
+ * @author Martin Kouba
+ */
+class DestroyedLiteral extends AnnotationLiteral<Destroyed> implements Destroyed {
+
+    private static final long serialVersionUID = 1L;
+
+    private final Class<? extends Annotation> value;
+
+    public static DestroyedLiteral of(Class<? extends Annotation> value) {
+        return new DestroyedLiteral(value);
+    }
+
+    private DestroyedLiteral(Class<? extends Annotation> value) {
+        this.value = value;
+    }
+
+    public Class<? extends Annotation> value() {
+        return value;
+    }
+}
diff --git a/junit-common/src/main/java/org/jboss/weld/junit/InitializedLiteral.java b/junit-common/src/main/java/org/jboss/weld/junit/InitializedLiteral.java
new file mode 100644
index 0000000..7e9e7b5
--- /dev/null
+++ b/junit-common/src/main/java/org/jboss/weld/junit/InitializedLiteral.java
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit;
+
+import java.lang.annotation.Annotation;
+
+import javax.enterprise.context.Initialized;
+import javax.enterprise.util.AnnotationLiteral;
+
+/**
+ * Supports inline instantiation of the {@link Initialized} qualifier.
+ *
+ * @author Martin Kouba
+ */
+class InitializedLiteral extends AnnotationLiteral<Initialized> implements Initialized {
+
+    private static final long serialVersionUID = 1L;
+
+    private final Class<? extends Annotation> value;
+
+    public static InitializedLiteral of(Class<? extends Annotation> value) {
+        return new InitializedLiteral(value);
+    }
+
+    private InitializedLiteral(Class<? extends Annotation> value) {
+        this.value = value;
+    }
+
+    public Class<? extends Annotation> value() {
+        return value;
+    }
+}
diff --git a/junit-common/src/main/java/org/jboss/weld/junit/WeldCDIExtension.java b/junit-common/src/main/java/org/jboss/weld/junit/WeldCDIExtension.java
index 3ba7a59..f4b1ba6 100644
--- a/junit-common/src/main/java/org/jboss/weld/junit/WeldCDIExtension.java
+++ b/junit-common/src/main/java/org/jboss/weld/junit/WeldCDIExtension.java
@@ -24,6 +24,7 @@ import java.util.Set;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Extension;
 
 /**
@@ -45,10 +46,10 @@ class WeldCDIExtension implements Extension {
         this.contexts = new ArrayList<>();
     }
 
-    void afterBeandiscovery(@Observes AfterBeanDiscovery event) {
+    void afterBeandiscovery(@Observes AfterBeanDiscovery event, BeanManager beanManager) {
         if (scopesToActivate != null) {
             for (Class<? extends Annotation> scope : scopesToActivate) {
-                ContextImpl ctx = new ContextImpl(scope);
+                ContextImpl ctx = new ContextImpl(scope, beanManager);
                 contexts.add(ctx);
                 event.addContext(ctx);
             }
diff --git a/junit4/src/main/java/org/jboss/weld/junit4/WeldInitiator.java b/junit4/src/main/java/org/jboss/weld/junit4/WeldInitiator.java
index 38f5ec2..5c0bb7f 100644
--- a/junit4/src/main/java/org/jboss/weld/junit4/WeldInitiator.java
+++ b/junit4/src/main/java/org/jboss/weld/junit4/WeldInitiator.java
@@ -37,6 +37,8 @@ import org.junit.runners.model.Statement;
  * JUnit 4 initiator - test rule which starts a Weld container per each test method execution:
  *
  * <pre>
+ * import org.junit.Rule;
+ *
  * public class SimpleTest {
  *
  *     &#64;Rule
@@ -52,6 +54,32 @@ import org.junit.runners.model.Statement;
  * </pre>
  *
  * <p>
+ * Alternatively, the container can be shared accross all test methods:
+ * </p>
+ *
+ * <pre>
+ * import org.junit.ClassRule;
+ *
+ * public class ClassRuleTest {
+ *
+ *     &#64;ClassRule
+ *     public WeldInitiator weld = WeldInitiator.of(Foo.class);
+ *
+ *     &#64;Test
+ *     public void test1() {
+ *         // Weld container is started automatically
+ *         // WeldInitiator can be used to perform programmatic lookup of beans
+ *         assertEquals("baz", weld.select(Foo.class).get().getBaz());
+ *     }
+ *
+ *     &#64;Test
+ *     public void test2() {
+ *         // This test method is using the same Weld container as test1()
+ *     }
+ * }
+ * </pre>
+ *
+ * <p>
  * {@link WeldInitiator} implements {@link Instance} and therefore might be used to perform programmatic lookup of bean
  * instances.
  * </p>
diff --git a/junit5/README.md b/junit5/README.md
index 67816c3..044a683 100644
--- a/junit5/README.md
+++ b/junit5/README.md
@@ -1,27 +1,39 @@
-# Weld JUnit 5 Extension
+# Weld JUnit 5 Extensions
 
-This extension uses the extension mechanism introduced in JUnit 5.
-Therefore, in order to use this extension in your test, you have to annotate your test class with `@ExtendWith(WeldJunit5Extension.class)`.
-It will automatically inject into all your `@Inject` fields in given test instance and start/stop Weld SE container based on your configuration.
-Even if no configuration is provided, the default one will kick in.
-Supports both test lifecycles - per method and per class.
+There are two extension here, both of which follow the extension mechanism introduced in JUnit 5.
+Therefore, in order to use this extension in your test, you have to annotate your test class with `@ExtendWith(WeldJunit5Extension.class)` or `@ExtendWith(WeldJunit5AutoExtension.class)` respectively.
+In their default behaviour, the extensions will automatically start/stop Weld SE container and inject into all your `@Inject` fields and method parameters in the given test instance.
+Furthermore you can provide configuration and modify Weld bootstrapping process in various ways - extensions, scope activation, interception, ...
 
-Requires JUnit 5 and Java 8.
+The extensions support both test lifecycles - per method and per class.
+
+Requirements are JUnit 5 and Java 8.
 
 ## Table of contents
 
 * [Maven Artifact](#maven-artifact)
-* [Basic Example](#basic-example)
-* [WeldInitiator](#weldinitiator)
-  * [Flat Deployment](#flat-deployment)
-  * [Convenient Starting Points](#convenient-starting-points)
-    * [Test class injection](#test-class-injection)
-    * [Activating context for a normal scope](#activating-context-for-a-normal-scope)
-    * [Adding mock beans](#adding-mock-beans)
-    * [Adding mock interceptors](#adding-mock-interceptors)
-    * [Mock injection services](#mock-injection-services)
+* [Configuration Versus Automagic](#configuration-versus-automagic)
+* [WeldJunit5Extension](#weldjunit5extension)
+  * [WeldInitiator](#weldinitiator)
+    * [Convenient Starting Points](#convenient-starting-points)
+      * [Test class injection](#test-class-injection)
+      * [Activating context for a normal scope](#activating-context-for-a-normal-scope)
+      * [Adding mock beans](#adding-mock-beans)
+      * [Adding mock interceptors](#adding-mock-interceptors)
+      * [Mock injection services](#mock-injection-services)
+* [WeldJunit5AutoExtension](#weldjunit5autoextension)
+  * [`@ActivateScopes`](#activate-scopes)
+  * [`@AddBeanClasses`](#add-bean-classes)
+  * [`@AddEnabledDecorators`](#add-enabled-decorators)
+  * [`@AddEnabledInterceptors`](#add-enabled-interceptors)
+  * [`@AddExtensions`](#add-extensions)
+  * [`@AddPackages`](#add-packages)
+  * [`@EnableAlternativeStereotypes`](#enable-alternative-stereotypes)
+  * [`@EnableAlternatives`](#enable-alternatives)
+  * [`@OverrideBean`](#override-bean)
 * [Additional Configuration](#additional-configuration)
   * [Explicit Parameter Injection](#explicit-parameter-injection)
+  * [Flat Deployment](#flat-deployment)
 
 ## Maven Artifact
 
@@ -33,11 +45,30 @@ Requires JUnit 5 and Java 8.
 </dependency>
 ```
 
-## Basic Example
+## Configuration Versus Automagic
+
+There are two extensions you can choose from.
+While both are ultimately achieving the same thing, each opts for a different approach.
+
+`WeldJunit5Extension.class` is the original one where you declaratively configure the container, much like booting Weld SE itself.
+There are some additional builder patterns on top of that allowing for easy addition of mocked beans and such.
+The advantage of this approach is that you have complete control over what gets into Weld container and can easily change that.
+On the other hand, it may be rather verbose and requires you to add a specifically annotated field to every test (described below).
+
+`WeldJunit5AutoExtension.class` is more of an annotation based approach where you don't need any special field in your test class.
+In fact, you don't need anything except the JUnit `@ExtendWith` and our extension will try its best to find out what classes should be added to Weld container as beans.
+This of course makes some assumptions on your tests which may not always be met, hence there is bunch of annotations which allow you to configure the container.
+Pros of this approach are quick setup for basic cases, less verbose code and that eerie feeling that things are happening automagically.
+On the not so bright side, automatic config is not almighty and in some cases will falter forcing you to add some configuration via annotations.
+Last but not least, overly complex test scenarios may mean loads of annotations and you may be better off with the former extension.
+
+No matter what extension you choose, do not mix them together!
+
+## WeldJunit5Extension
 
 The simplest way to use this extension is to annotate your test class with `@ExtendWith(WeldJunit5Extension.class)`.
 If you are in for shorter annotations, you can also use `@EnableWeld`.
-In such case, Weld container will be started before each test is run and stopped afterwards.
+With just these annotations, Weld container will be started before each test is run and stopped afterwards.
 This default behaviour includes:
 
 * Bootstrapping Weld SE container with
@@ -71,7 +102,7 @@ class BasicUsageTest {
 }
 ```
 
-## WeldInitiator
+### WeldInitiator
 
 `org.jboss.weld.junit5.WeldInitiator` is an entry point you will want to define if you wish to customize how we bootstrap Weld.
 The container is configured through a provided `org.jboss.weld.environment.se.Weld` instance.
@@ -100,14 +131,7 @@ class MyNewTest {
 }
 ```
 
-### Flat Deployment
-
-Unlike when using [Arquillian Weld embedded container](https://github.com/arquillian/arquillian-container-weld), bean archive isolation is enabled by default.
-This behaviour can be changed by setting a system property `org.jboss.weld.se.archive.isolation` to `false` or through the `Weld.property()` method.
-In that case, Weld will use a _"flat"_ deployment structure - all bean classes share the same bean archive and all beans.xml descriptors are automatically merged into one.
-Thus alternatives, interceptors and decorators selected/enabled for a bean archive will be enabled for the whole application.
-
-### Convenient Starting Points
+#### Convenient Starting Points
 
 A convenient static method `WeldInitiator.of(Class<?>...)` is also provided - in this case, the container is optimized for testing purposes and only the given bean classes are considered.
 
@@ -154,7 +178,7 @@ class AnotherSimpleTest {
 
 Furthermore, `WeldInitiator.Builder` can be used to customize the final `WeldInitiator` instance, e.g. to *activate a context for a given normal scope* or to *inject the test class*.
 
-#### Test class injection
+##### Test class injection
 
 Everytime `WeldJunit5Extension` processes your test instance, it will automatically resolve all `@Inject` fields as well as attempt to resolve any test method parameters, should they be injectable beans.
 
@@ -178,7 +202,7 @@ class InjectTest {
 }
 ```
 
-#### Activating context for a normal scope
+##### Activating context for a normal scope
 
 `WeldInitiator.Builder.activate(Class<? extends Annotation>...)` makes it possible to activate and deactivate contexts for the specified normal scopes for each test method execution:
 
@@ -201,7 +225,7 @@ class ContextsActivatedTest {
 }
 ```
 
-#### Adding mock beans
+##### Adding mock beans
 
 Sometimes you might need to add a mock for a bean that cannot be part of the test deployment, e.g. the original bean implementation has dependencies which cannot be satisfied in the test environment.
 Very often, it's an ideal use case for mocking libraries, ie. to create a bean instance with the desired behavior.
@@ -285,7 +309,7 @@ class AddBeanTest {
 }
 ```
 
-#### Adding mock interceptors
+##### Adding mock interceptors
 
 Sometimes it might be useful to add a mock interceptor, e.g. if an interceptor implementation requires some environment-specific features.
 For this use case the `org.jboss.weld.junit.MockInterceptor` is a perfect match:
@@ -327,7 +351,7 @@ class MockInterceptorTest {
 }
 ```
 
-#### Mock injection services
+##### Mock injection services
 
 If a bean under the test declares a non-CDI injection point (such as `@Resource`) a mock injection service must be installed.
 `WeldInitiator` builder comes with several convenient methods which allow to easily mock the Weld SPI:
@@ -357,6 +381,133 @@ class MyTest {
     }
 }
 ```
+## WeldJunit5AutoExtension
+
+To use this approach, annotate your test class with `ExtendWith(WeldJunit5AutoExtension.class)` or just `@EnableAutoWeld`.
+By default, the extension will:
+
+* Inspect your test class and try to figure out what beans classes it needs based on injection points (field and parameter injection both work)
+  * This is done by finding classes and verifying if they have [bean defining annotation](http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#bean_defining_annotations) so make sure they do
+* Add those classes to Weld container
+* Process additional annotations on test class
+  * `@AddPackages`, `@AddExtensions`, `@ActivateScopes`, ...
+* Bootstrap Weld container
+* Inject into test instance, e.g. into all `@Inject` fields
+* Inject into method parameters of your test methods
+  * In case the type of the parameter matches a known and resolvable bean
+  * By default, Weld is greedy and will try to resolve all parameters which are known as bean types in CDI container
+  * If you wish to change this behaviour, please refer to [additional configuration section](#explicit-parameter-injection)
+* Shutting down the container after test is done
+
+Here is a simple example using the default plus one additional annotation (`@AddPackages`):
+
+```java
+import org.jboss.weld.junit5.auto.beans.Engine;
+import org.jboss.weld.junit5.auto.beans.V8;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import javax.inject.Inject;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+@EnableAutoWeld
+@AddPackages(Engine.class) // turn all legitimate classes inside Engine's package into CDI beans
+public class BasicAutomagicTest {
+
+  @Inject
+  private V8 v8Engine;
+
+  @Inject
+  private V6 v6Engine;
+
+  @Test
+  void test() {
+    assertNotNull(V8Engine);
+    assertNotNull(v6Engine);
+  }
+
+}
+```
+
+The default behaviour is powerful enough to handle basic cases where you simply want to inject a bean make assertions on it.
+However, it will not be enough if you want to, say, test your CDI extensions, enable custom interceptors or make sure certain scopes are active.
+Or if you want to inject interfaces instead of implementations of beans.
+For those cases, and many others, there are special annotations you can use - we will go over them, one at a time.
+At the end there is an example showing several of them.
+
+### `@ActivateScopes`
+
+Normally, only `@ApplicationScoped` and `@Dependent` beans work without any additional settings.
+`@ActivateScopes` annotation allows you to list scopes which are to be actived for the duration of the test.
+Note that the duration is dependent on your setting of JUnit test lifecycle - it can be either per method or per class.
+
+### `@AddBeanClasses`
+
+Using this annotation you can specify a list of Java classes which will be registered as beans with Weld container.
+Note that standard rules for beans apply (proxiability for instance).
+
+This can be handy if you wish to operate with interfaces rather than implementation classes as the class scanning performed by the extension
+cannot know for sure which class is the implementation of given interface.
+
+### `@AddEnabledDecorators`
+
+Adds the decorator class into deployment and enables it.
+
+### `@AddEnabledInterceptors`
+
+Adds the interceptor class into deployment and enables it.
+
+### `@AddExtensions`
+
+Registers one or more extensions within Weld container; this is programmatic replacement for placing the extension in `META-INF`.
+
+### `@AddPackages`
+
+Adds all bean classes from listed packages to Weld container.
+Packages are selected by providing any bean class in the package.
+You can also specify if this should be done recursively using the `recursive` parameter.
+
+### `@EnableAlternativeStereotypes`
+
+Enables given alternative stereotype.
+
+### `@EnableAlternatives`
+
+Selects and alternative for the test bean archive.
+
+### `@OverrideBean`
+
+This annotations covers a rather specific use case, it allows to "override a bean" which may otherwise be included in the container.
+It usually goes hand in hand with `@Produces` which is a natural way to provide a replacement bean.
+Strictly speaking, this is just an always enabled alternative stereotype.
+Let's look at a code snippet:
+
+```java
+import org.jboss.weld.junit5.auto.AddPackages;
+import org.jboss.weld.junit5.auto.OverrideBean;
+import org.jboss.weld.junit5.auto.WeldJunit5AutoExtension;
+import org.junit.jupiter.api.Test;
+
+import javax.enterprise.inject.Produces;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+ @EnableAutoWeld
+ @AddPackages(Foo.class) // this brings in the *original* Foo impl you want to overide
+ class OverrideFooTest {
+ 
+   @Produces
+   @OverrideBean
+   Foo fakeFoo = new Foo("non-baz"); // this will be an enabled alternative we provide instead
+ 
+   @Test
+   void test(Foo myFoo) {
+     assertNotNull(myFoo);
+     assertEquals(myFoo.getBar(), "non-baz");
+   }
+}
+```
 
 ## Additional Configuration
 
@@ -396,3 +547,11 @@ class ExplicitParamInjectionTest {
 
 As you might know, if you want to inject a bean where you would normally not use any qualifier, you can do that using `@Default` qualifier (as shown in the code above).
 This is in accordance with CDI specification, feel free to [read more about it](http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#builtin_qualifiers).
+
+#### Flat Deployment
+
+Unlike [Arquillian Weld embedded container](https://github.com/arquillian/arquillian-container-weld), weld-junit has bean archive isolation enabled by default.
+This behaviour can be changed by setting a system property `org.jboss.weld.se.archive.isolation` to `false` or through the `Weld.property()` method.
+If set, Weld will use a _"flat"_ deployment structure - all bean classes share the same bean archive and all beans.xml descriptors are automatically merged into one.
+Thus alternatives, interceptors and decorators selected/enabled for a bean archive will be enabled for the whole application.
+Note that this configuration only makes difference if you run with *enabled discovery*; it won't affect your deployment if you use synthetic bean archive.
diff --git a/junit5/src/main/java/org/jboss/weld/junit5/EnableWeld.java b/junit5/src/main/java/org/jboss/weld/junit5/EnableWeld.java
index ba27580..1bc5c27 100644
--- a/junit5/src/main/java/org/jboss/weld/junit5/EnableWeld.java
+++ b/junit5/src/main/java/org/jboss/weld/junit5/EnableWeld.java
@@ -26,8 +26,8 @@ import java.lang.annotation.Target;
 import org.junit.jupiter.api.extension.ExtendWith;
 
 /**
- * Meta-annotation that allows test classes to be extended with <code>&#64;EnableWeld</code>
- * instead of <code>&#64;ExtendWith(WeldJunit5Extension.class)</code>.
+ * Meta-annotation that allows test classes to be extended with {@code @EnableWeld}
+ * instead of {@code @ExtendWith(WeldJunit5Extension.class)}.
  *
  * <pre><br>
  * &#64;EnableWeld
@@ -46,6 +46,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
  * </pre>
  *
  * @author <a href="mailto:smoyer1@selesy.com">Steve Moyer</a>
+ * @see WeldJunit5Extension
  */
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ ElementType.TYPE, ElementType.METHOD })
diff --git a/junit5/src/main/java/org/jboss/weld/junit5/ExtensionContextUtils.java b/junit5/src/main/java/org/jboss/weld/junit5/ExtensionContextUtils.java
index cf7f298..60f7a0f 100644
--- a/junit5/src/main/java/org/jboss/weld/junit5/ExtensionContextUtils.java
+++ b/junit5/src/main/java/org/jboss/weld/junit5/ExtensionContextUtils.java
@@ -16,15 +16,16 @@
  */
 package org.jboss.weld.junit5;
 
+import java.util.List;
+
 import org.jboss.weld.environment.se.WeldContainer;
 import org.junit.jupiter.api.extension.ExtensionContext;
 import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
 
-import java.util.List;
-
-
 /**
- * Utility methods for fetching/storing items stored in the JUnit extension context.
+ * <b>This class is not a public API and it's contents can change unpredictably!</b>
+ *
+ * It contains utility methods for fetching/retrieving items stored in the JUnit extension context store.
  */
 public class ExtensionContextUtils {
 
@@ -35,26 +36,34 @@ public class ExtensionContextUtils {
     private static final String WELD_ENRICHERS = "weldEnrichers";
 
     private static Namespace EXTENSION_NAMESPACE;
-    private static Namespace TEST_NAMESPACE;
+
+    // private constructor to prevent instantiation
+    private ExtensionContextUtils() {        
+    }
 
     /**
-     * We use custom namespace based on this extension class
+     * We use custom namespace based on this extension class; can be stored as static variable as it doesn't change throughout
+     * testsuite execution.
+     *
+     * @param context {@link ExtensionContext} you are currently using
+     * @return <b>Root</b> {@link ExtensionContext.Store} with {@link Namespace} based on extension class alone
      */
-    public static synchronized ExtensionContext.Store getExtensionStore(ExtensionContext context) {
+    private static synchronized ExtensionContext.Store getRootExtensionStore(ExtensionContext context) {
         if (EXTENSION_NAMESPACE == null) {
-            EXTENSION_NAMESPACE = Namespace.create(WeldJunit5Extension.class, context.getRequiredTestClass());
+            EXTENSION_NAMESPACE = Namespace.create(WeldJunit5Extension.class);
         }
-        return context.getStore(EXTENSION_NAMESPACE);
+        return context.getRoot().getStore(EXTENSION_NAMESPACE);
     }
 
     /**
-     * We use custom namespace based on this extension class and test class
+     * We use custom namespace based on this extension class and test class, cannot be stored as static variable as test class
+     * name changes throughout testsuite execution
+     *
+     * @param context {@link ExtensionContext} you are currently using
+     * @return {@link ExtensionContext.Store} based on {@link ExtensionContext} and the required test class
      */
-    public static synchronized ExtensionContext.Store getTestStore(ExtensionContext context) {
-        if (TEST_NAMESPACE == null) {
-            TEST_NAMESPACE = Namespace.create(WeldJunit5Extension.class, context.getRequiredTestClass());
-        }
-        return context.getStore(TEST_NAMESPACE);
+    private static ExtensionContext.Store getTestStore(ExtensionContext context) {
+        return context.getStore(Namespace.create(WeldJunit5Extension.class, context.getRequiredTestClass()));
     }
 
     /**
@@ -65,7 +74,7 @@ public class ExtensionContextUtils {
     }
 
     /**
-     * Store initiator to extension context
+     * Stores {@link WeldInitiator} into provided {@link ExtensionContext.Store} based on provided {@link ExtensionContext}
      */
     public static void setInitiatorToStore(ExtensionContext context, WeldInitiator initiator) {
         getTestStore(context).put(INITIATOR, initiator);
@@ -80,7 +89,7 @@ public class ExtensionContextUtils {
     }
 
     /**
-     * Store explicit injection parameter to extension context
+     * Store explicit injection parameter to {@link ExtensionContext.Store} based on provided {@link ExtensionContext}
      */
     public static void setExplicitInjectionInfoToStore(ExtensionContext context, boolean value) {
         getTestStore(context).put(EXPLICIT_PARAM_INJECTION, value);
@@ -88,13 +97,16 @@ public class ExtensionContextUtils {
 
     /**
      * Can return null if WeldContainer isn't stored yet
+     *
+     * @param context {@link ExtensionContext} to search in
+     * @return {@link WeldContainer} or null if it wasn't stored yet
      */
     public static WeldContainer getContainerFromStore(ExtensionContext context) {
         return getTestStore(context).get(CONTAINER, WeldContainer.class);
     }
 
     /**
-     * Store container to extension context
+     * Store {@link WeldContainer} to {@link ExtensionContext.Store}
      */
     public static void setContainerToStore(ExtensionContext context, WeldContainer container) {
         getTestStore(context).put(CONTAINER, container);
@@ -102,18 +114,21 @@ public class ExtensionContextUtils {
 
     /**
      * Can return null if `WeldJunitEnricher`s aren't stored yet.
+     *
+     * @param context {@link ExtensionContext} to search in
+     * @return {@code List<WeldJunitEnricher>} or null in case they weren't stored yet
      */
     public static List<WeldJunitEnricher> getEnrichersFromStore(ExtensionContext context) {
         @SuppressWarnings("unchecked")
-        List<WeldJunitEnricher> enrichers = (List<WeldJunitEnricher>) getExtensionStore(context).get(WELD_ENRICHERS, List.class);
+        List<WeldJunitEnricher> enrichers = (List<WeldJunitEnricher>) getRootExtensionStore(context).get(WELD_ENRICHERS, List.class);
         return enrichers;
     }
 
     /**
-     * Store `WeldJunitEnricher`s to extension context
+     * Store `WeldJunitEnricher`s to <i>root</i> extension context
      */
     public static void setEnrichersToStore(ExtensionContext context, List<WeldJunitEnricher> enrichers) {
-        getExtensionStore(context).put(WELD_ENRICHERS, enrichers);
+        getRootExtensionStore(context).put(WELD_ENRICHERS, enrichers);
     }
 
 }
diff --git a/junit5/src/main/java/org/jboss/weld/junit5/auto/ActivateScopes.java b/junit5/src/main/java/org/jboss/weld/junit5/auto/ActivateScopes.java
index d659eea..05f69a4 100644
--- a/junit5/src/main/java/org/jboss/weld/junit5/auto/ActivateScopes.java
+++ b/junit5/src/main/java/org/jboss/weld/junit5/auto/ActivateScopes.java
@@ -24,9 +24,14 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+import org.junit.jupiter.api.TestInstance;
+
 
 /**
  * Activates the listed scopes for the duration of the test.
+ *
+ * Note that the duration will either be that of one test method or one test class based on your settings of
+ * {@link TestInstance.Lifecycle}.
  */
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.TYPE})
diff --git a/junit5/src/main/java/org/jboss/weld/junit5/auto/ClassScanning.java b/junit5/src/main/java/org/jboss/weld/junit5/auto/ClassScanning.java
index dad4e82..2def830 100644
--- a/junit5/src/main/java/org/jboss/weld/junit5/auto/ClassScanning.java
+++ b/junit5/src/main/java/org/jboss/weld/junit5/auto/ClassScanning.java
@@ -65,7 +65,7 @@ import static org.junit.platform.commons.support.AnnotationSupport.isAnnotated;
 /**
  * Provides <b>automagic</b> bean class discovery for a test class instance.
  */
-public class ClassScanning {
+class ClassScanning {
 
     public static void scanForRequiredBeanClass(Class<?> testClass, Weld weld, boolean explicitInjection) {
 
@@ -73,7 +73,6 @@ public class ClassScanning {
         classesToProcess.add(testClass);
 
         Set<Class<?>> foundClasses = new HashSet<>();
-        Set<Class<?>> alternatives = new HashSet<>();
 
         while (!classesToProcess.isEmpty()) {
 
@@ -85,14 +84,6 @@ public class ClassScanning {
 
             foundClasses.add(currClass);
 
-            findAnnotatedFields(currClass, Object.class, OverrideBean.class).stream()
-                    .map(Field::getType)
-                    .forEach(alternatives::add);
-
-            AnnotationSupport.findAnnotatedMethods(currClass, OverrideBean.class, HierarchyTraversalMode.BOTTOM_UP).stream()
-                    .map(Method::getReturnType)
-                    .forEach(alternatives::add);
-
             findAnnotatedFields(currClass, Object.class, Inject.class).stream()
                     .map(Field::getType)
                     .forEach(cls -> addClassesToProcess(classesToProcess, cls));
@@ -158,12 +149,18 @@ public class ClassScanning {
             AnnotationSupport.findRepeatableAnnotations(currClass, AddEnabledInterceptors.class).stream()
                     .flatMap(ann -> stream(ann.value()))
                     .distinct()
-                    .forEach(weld::addInterceptor);
+                    .forEach(interceptor -> {
+                        weld.addInterceptor(interceptor);
+                        weld.addBeanClass(interceptor);
+                    });
 
             AnnotationSupport.findRepeatableAnnotations(currClass, AddEnabledDecorators.class).stream()
                     .flatMap(ann -> stream(ann.value()))
                     .distinct()
-                    .forEach(weld::addDecorator);
+                    .forEach(decorator -> {
+                        weld.addDecorator(decorator);
+                        weld.addBeanClass(decorator);
+                    });
 
             AnnotationSupport.findRepeatableAnnotations(currClass, EnableAlternatives.class).stream()
                     .flatMap(ann -> stream(ann.value()))
@@ -177,7 +174,6 @@ public class ClassScanning {
 
         }
 
-        foundClasses.removeAll(alternatives);
         foundClasses.add(testClass);
 
         for (Class<?> foundClass : foundClasses) {
diff --git a/junit5/src/main/java/org/jboss/weld/junit5/auto/EnableAutoWeld.java b/junit5/src/main/java/org/jboss/weld/junit5/auto/EnableAutoWeld.java
index 6030208..e3d5187 100644
--- a/junit5/src/main/java/org/jboss/weld/junit5/auto/EnableAutoWeld.java
+++ b/junit5/src/main/java/org/jboss/weld/junit5/auto/EnableAutoWeld.java
@@ -26,8 +26,8 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
 /**
- * Meta-annotation that allows test classes to be extended with <code>&#64;EnableWeld</code>
- * instead of <code>&#64;ExtendWith(WeldJunit5Extension.class)</code>.
+ * Meta-annotation that allows test classes to be extended with {@code @EnableAutoWeld}
+ * instead of {@code @ExtendWith(WeldJunit5AutoExtension.class)}.
  *
  * <pre><br>
  * &#64;EnableAutoWeld
@@ -45,7 +45,7 @@ import java.lang.annotation.Target;
  * }
  * </pre>
  *
- * @author <a href="mailto:smoyer1@selesy.com">Steve Moyer</a>
+ * @see WeldJunit5AutoExtension
  */
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ ElementType.TYPE, ElementType.METHOD })
diff --git a/junit5/src/main/java/org/jboss/weld/junit5/auto/OverrideBean.java b/junit5/src/main/java/org/jboss/weld/junit5/auto/OverrideBean.java
index 0c72b07..de3f392 100644
--- a/junit5/src/main/java/org/jboss/weld/junit5/auto/OverrideBean.java
+++ b/junit5/src/main/java/org/jboss/weld/junit5/auto/OverrideBean.java
@@ -26,14 +26,33 @@ import java.lang.annotation.Target;
 
 
 /**
- * Overrides a bean class that <i>may</i> otherwise be included in the container.
+ * {@code @OverrideBean} is, strictly speaking, an always enabled alternative stereotype.
+ * It is typically used along with {@code @javax.enterprise.inject.Produces}.
  *
- * Using this annotation provides an easy way to replace a bean class during a
- * test; It is usually used along with {@link javax.enterprise.inject.Produces}.
+ * It "overrides a bean" that <i>may</i> otherwise be included in the container by providing a new bean (via producer) and
+ * selecting it.
+ *
+ * Here is how such a usage can look like:
+ * <pre>
+ * &#64;EnableAutoWeld
+ * &#64;AddPackages(Foo.class) // this brings in the *original* Foo impl you want to override
+ * class OverrideFooTest {
+ * 
+ *   &#64;Produces
+ *   &#64;OverrideBean
+ *   Foo fakeFoo = new Foo("non-baz");
+ * 
+ *   &#64;Test
+ *   void test(Foo myFoo) {
+ *     assertNotNull(myFoo);
+ *     assertEquals(myFoo.getBar(), "non-baz");
+ *   }
+ * }
+ * </pre>
  */
 @Stereotype
 @Alternative
 @Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER})
+@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
 public @interface OverrideBean {
 }
diff --git a/junit5/src/main/java/org/jboss/weld/junit5/auto/WeldJunit5AutoExtension.java b/junit5/src/main/java/org/jboss/weld/junit5/auto/WeldJunit5AutoExtension.java
index 704d35c..d080f28 100644
--- a/junit5/src/main/java/org/jboss/weld/junit5/auto/WeldJunit5AutoExtension.java
+++ b/junit5/src/main/java/org/jboss/weld/junit5/auto/WeldJunit5AutoExtension.java
@@ -23,7 +23,30 @@ import org.junit.platform.commons.support.AnnotationSupport;
 
 import static org.jboss.weld.junit5.ExtensionContextUtils.getExplicitInjectionInfoFromStore;
 
-public class WeldJunit5AutoExtension extends org.jboss.weld.junit5.WeldJunit5Extension {
+import org.jboss.weld.junit5.WeldJunit5Extension;
+import org.jboss.weld.junit5.WeldJunitEnricher;
+
+/**
+ * An alternative to {@link WeldJunit5Extension} allowing to fully leverage annotation based configuration approach.
+ * When used, the extension will attempt to resolve all beans used in your test class and automatically adds them to
+ * Weld container while bootstrapping it.
+ * 
+ * There is quite a few annotations which can be used to configure it further still:
+ * @see ActivateScopes
+ * @see AddBeanClasses
+ * @see AddEnabledDecorators
+ * @see AddEnabledInterceptors
+ * @see AddExtensions
+ * @see AddPackages
+ * @see EnableAlternatives
+ * @see EnableAlternativeStereotypes
+ *
+ * Note that this approach cannot be combined with {@link WeldJunit5Extension}, choose one or the other approach, not both.
+ *
+ * @see EnableAutoWeld
+ * @see WeldJunitEnricher
+ */
+public class WeldJunit5AutoExtension extends WeldJunit5Extension {
 
     @Override
     protected void weldInit(Object testInstance, ExtensionContext context, Weld weld, WeldInitiator.Builder weldInitiatorBuilder) {


Test patch:
diff --git a/junit4/src/test/java/org/jboss/weld/junit4/contexts/events/ContextLifecycleEventsObserver.java b/junit4/src/test/java/org/jboss/weld/junit4/contexts/events/ContextLifecycleEventsObserver.java
new file mode 100644
index 0000000..79a8687
--- /dev/null
+++ b/junit4/src/test/java/org/jboss/weld/junit4/contexts/events/ContextLifecycleEventsObserver.java
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit4.contexts.events;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.Destroyed;
+import javax.enterprise.context.Initialized;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+
+@ApplicationScoped
+public class ContextLifecycleEventsObserver {
+
+    static final List<String> EVENTS = new CopyOnWriteArrayList<>();
+
+    void onRequestContextInit(@Observes @Initialized(RequestScoped.class) Object event) {
+        EVENTS.add(Initialized.class.getName() + RequestScoped.class.getName());
+    }
+
+    void onRequestContextDestroy(@Observes @Destroyed(RequestScoped.class) Object event) {
+        EVENTS.add(Destroyed.class.getName() + RequestScoped.class.getName());
+    }
+
+    void onSessionContextInit(@Observes @Initialized(SessionScoped.class) Object event) {
+        EVENTS.add(Initialized.class.getName() + SessionScoped.class.getName());
+    }
+
+    void onSessionContextDestroy(@Observes @Destroyed(SessionScoped.class) Object event) {
+        EVENTS.add(Destroyed.class.getName() + SessionScoped.class.getName());
+    }
+
+}
diff --git a/junit4/src/test/java/org/jboss/weld/junit4/contexts/events/ContextLifecycleEventsTest.java b/junit4/src/test/java/org/jboss/weld/junit4/contexts/events/ContextLifecycleEventsTest.java
new file mode 100644
index 0000000..63f5110
--- /dev/null
+++ b/junit4/src/test/java/org/jboss/weld/junit4/contexts/events/ContextLifecycleEventsTest.java
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2017, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit4.contexts.events;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.enterprise.context.Destroyed;
+import javax.enterprise.context.Initialized;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+
+import org.jboss.weld.junit4.WeldInitiator;
+import org.junit.AfterClass;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ *
+ * @author Martin Kouba
+ */
+public class ContextLifecycleEventsTest {
+
+    @Rule
+    public WeldInitiator initiator = WeldInitiator.from(ContextLifecycleEventsObserver.class).activate(RequestScoped.class, SessionScoped.class).build();
+
+    @Test
+    public void testInitFired() {
+        // At this time @Initialized should be fired
+        assertTrue(ContextLifecycleEventsObserver.EVENTS.contains(Initialized.class.getName() + RequestScoped.class.getName()));
+        assertTrue(ContextLifecycleEventsObserver.EVENTS.contains(Initialized.class.getName() + SessionScoped.class.getName()));
+    }
+
+    @AfterClass
+    public static void afterAll() {
+        // At this time @Destroyed from the previous test method should be fired
+        assertTrue(ContextLifecycleEventsObserver.EVENTS.contains(Destroyed.class.getName() + RequestScoped.class.getName()));
+        assertTrue(ContextLifecycleEventsObserver.EVENTS.contains(Destroyed.class.getName() + SessionScoped.class.getName()));
+    }
+
+}
diff --git a/junit5/src/main/java/org/jboss/weld/junit5/auto/TestInstanceInjectionExtension.java b/junit5/src/main/java/org/jboss/weld/junit5/auto/TestInstanceInjectionExtension.java
index 5b34eb9..41cb3db 100644
--- a/junit5/src/main/java/org/jboss/weld/junit5/auto/TestInstanceInjectionExtension.java
+++ b/junit5/src/main/java/org/jboss/weld/junit5/auto/TestInstanceInjectionExtension.java
@@ -77,9 +77,6 @@ public class TestInstanceInjectionExtension implements Extension {
         this.testInstance = testInstance;
     }
 
-    TestInstanceInjectionExtension() {
-    }
-
     <T> void rewriteTestClassScope(@Observes ProcessAnnotatedType<T> pat, BeanManager beanManager) {
 
         AnnotatedType<T> annotatedType = pat.getAnnotatedType();
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/auto/AddDecoratorTest.java b/junit5/src/test/java/org/jboss/weld/junit5/auto/AddDecoratorTest.java
new file mode 100644
index 0000000..0ac0213
--- /dev/null
+++ b/junit5/src/test/java/org/jboss/weld/junit5/auto/AddDecoratorTest.java
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit5.auto;
+
+import javax.inject.Inject;
+
+import org.jboss.weld.junit5.auto.interceptorAndDecorator.DecoratedBean;
+import org.jboss.weld.junit5.auto.interceptorAndDecorator.TestDecorator;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+/**
+ *
+ * @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a>
+ */
+/**
+ * Test that you can add decorator class and enable it (no need for priority) via annotation.
+ *
+ * @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a>
+ */
+@EnableAutoWeld
+@AddEnabledDecorators(TestDecorator.class)
+public class AddDecoratorTest {
+    
+    @Inject
+    DecoratedBean bean;
+    
+    @Test
+    public void testBeanIsDecorated() {
+        Assertions.assertNotNull(bean);
+        Assertions.assertEquals(TestDecorator.class.toString() + DecoratedBean.class.toString(), bean.ping());
+    }
+}
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/auto/AddInterceptorTest.java b/junit5/src/test/java/org/jboss/weld/junit5/auto/AddInterceptorTest.java
new file mode 100644
index 0000000..6eb1af8
--- /dev/null
+++ b/junit5/src/test/java/org/jboss/weld/junit5/auto/AddInterceptorTest.java
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit5.auto;
+
+import javax.inject.Inject;
+
+import org.jboss.weld.junit5.auto.interceptorAndDecorator.InterceptedBean;
+import org.jboss.weld.junit5.auto.interceptorAndDecorator.TestInterceptor;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test that you can add interceptor class and enable it (no need for priority) via annotation.
+ *
+ * @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a>
+ */
+@EnableAutoWeld
+@AddEnabledInterceptors(TestInterceptor.class)
+public class AddInterceptorTest {
+    
+    @Inject
+    InterceptedBean bean;
+    
+    @Test
+    public void testBeanIsIntercepted() {
+        Assertions.assertNotNull(bean);
+        Assertions.assertEquals(TestInterceptor.class.toString() + InterceptedBean.class.toString(), bean.ping());
+    }
+}
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/auto/AddPackagesTest.java b/junit5/src/test/java/org/jboss/weld/junit5/auto/AddPackagesTest.java
index 2426b26..604522a 100644
--- a/junit5/src/test/java/org/jboss/weld/junit5/auto/AddPackagesTest.java
+++ b/junit5/src/test/java/org/jboss/weld/junit5/auto/AddPackagesTest.java
@@ -20,7 +20,7 @@ public class AddPackagesTest {
   private V8 engine;
 
   @Test
-  @DisplayName("Test that @AddPackages pulls in V8 to fulfill the injected Engine interface")
+  @DisplayName("Test that @AddPackages pulls in V8 (without bean defining annotation) to fulfill the injected Engine interface")
   void test() {
     assertNotNull(engine);
   }
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/auto/beans/V8.java b/junit5/src/test/java/org/jboss/weld/junit5/auto/beans/V8.java
index 1532333..befb241 100644
--- a/junit5/src/test/java/org/jboss/weld/junit5/auto/beans/V8.java
+++ b/junit5/src/test/java/org/jboss/weld/junit5/auto/beans/V8.java
@@ -3,11 +3,6 @@ package org.jboss.weld.junit5.auto.beans;
 
 import java.io.Serializable;
 
-import javax.enterprise.context.ApplicationScoped;
-
-
-
-@ApplicationScoped
 public class V8 implements Engine, Serializable {
 
   private int throttle = 0;
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/DecoratedBean.java b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/DecoratedBean.java
new file mode 100644
index 0000000..e96be75
--- /dev/null
+++ b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/DecoratedBean.java
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit5.auto.interceptorAndDecorator;
+
+import javax.enterprise.context.Dependent;
+
+/**
+ *
+ * @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a>
+ */
+@Dependent
+public class DecoratedBean implements DecoratedBeanInterface{
+
+    @Override
+    public String ping() {
+        return DecoratedBean.class.toString();
+    }
+    
+}
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/DecoratedBeanInterface.java b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/DecoratedBeanInterface.java
new file mode 100644
index 0000000..32abb59
--- /dev/null
+++ b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/DecoratedBeanInterface.java
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit5.auto.interceptorAndDecorator;
+
+/**
+ *
+ * @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a>
+ */
+public interface DecoratedBeanInterface {
+    
+    public String ping();
+}
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/InterceptedBean.java b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/InterceptedBean.java
new file mode 100644
index 0000000..c04a25d
--- /dev/null
+++ b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/InterceptedBean.java
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit5.auto.interceptorAndDecorator;
+
+import javax.enterprise.context.Dependent;
+
+/**
+ *
+ * @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a>
+ */
+@TestInterceptorBinding
+@Dependent
+public class InterceptedBean {
+    
+    public String ping() {
+        return InterceptedBean.class.toString();
+    }
+}
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestDecorator.java b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestDecorator.java
new file mode 100644
index 0000000..fbffe76
--- /dev/null
+++ b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestDecorator.java
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit5.auto.interceptorAndDecorator;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a>
+ */
+@Decorator
+public class TestDecorator implements DecoratedBeanInterface{
+    
+    @Inject
+    @Delegate
+    DecoratedBeanInterface delegate;
+
+    @Override
+    public String ping() {
+        return TestDecorator.class.toString() + delegate.ping();
+    }
+}
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestInterceptor.java b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestInterceptor.java
new file mode 100644
index 0000000..2cc6754
--- /dev/null
+++ b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestInterceptor.java
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit5.auto.interceptorAndDecorator;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a>
+ */
+@Interceptor
+@TestInterceptorBinding
+public class TestInterceptor {
+    
+    @AroundInvoke
+    public Object intercept(InvocationContext ctx) throws Exception {
+        return TestInterceptor.class.toString() + ctx.proceed();
+    }
+}
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestInterceptorBinding.java b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestInterceptorBinding.java
new file mode 100644
index 0000000..354a3a5
--- /dev/null
+++ b/junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestInterceptorBinding.java
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit5.auto.interceptorAndDecorator;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+/**
+ *
+ * @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a>
+ */
+@InterceptorBinding
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface TestInterceptorBinding {
+    
+}
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/contexts/events/ContextLifecycleEventsObserver.java b/junit5/src/test/java/org/jboss/weld/junit5/contexts/events/ContextLifecycleEventsObserver.java
new file mode 100644
index 0000000..aad63f7
--- /dev/null
+++ b/junit5/src/test/java/org/jboss/weld/junit5/contexts/events/ContextLifecycleEventsObserver.java
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit5.contexts.events;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.Destroyed;
+import javax.enterprise.context.Initialized;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+
+@ApplicationScoped
+public class ContextLifecycleEventsObserver {
+
+    static final List<String> EVENTS = new CopyOnWriteArrayList<>();
+
+    void onRequestContextInit(@Observes @Initialized(RequestScoped.class) Object event) {
+        EVENTS.add(Initialized.class.getName() + RequestScoped.class.getName());
+    }
+
+    void onRequestContextDestroy(@Observes @Destroyed(RequestScoped.class) Object event) {
+        EVENTS.add(Destroyed.class.getName() + RequestScoped.class.getName());
+    }
+
+    void onSessionContextInit(@Observes @Initialized(SessionScoped.class) Object event) {
+        EVENTS.add(Initialized.class.getName() + SessionScoped.class.getName());
+    }
+
+    void onSessionContextDestroy(@Observes @Destroyed(SessionScoped.class) Object event) {
+        EVENTS.add(Destroyed.class.getName() + SessionScoped.class.getName());
+    }
+
+}
diff --git a/junit5/src/test/java/org/jboss/weld/junit5/contexts/events/ContextLifecycleEventsTest.java b/junit5/src/test/java/org/jboss/weld/junit5/contexts/events/ContextLifecycleEventsTest.java
new file mode 100644
index 0000000..9a5e7db
--- /dev/null
+++ b/junit5/src/test/java/org/jboss/weld/junit5/contexts/events/ContextLifecycleEventsTest.java
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2018, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.junit5.contexts.events;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import javax.enterprise.context.Destroyed;
+import javax.enterprise.context.Initialized;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+
+import org.jboss.weld.junit5.EnableWeld;
+import org.jboss.weld.junit5.WeldInitiator;
+import org.jboss.weld.junit5.WeldSetup;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
+
+/**
+ *
+ * @author Martin Kouba
+ */
+@EnableWeld
+public class ContextLifecycleEventsTest {
+
+    @WeldSetup
+    public WeldInitiator weld = WeldInitiator.from(ContextLifecycleEventsObserver.class).activate(RequestScoped.class, SessionScoped.class).build();
+
+    @Test
+    public void testInitFired() {
+        // At this time @Initialized should be fired
+        assertTrue(ContextLifecycleEventsObserver.EVENTS.contains(Initialized.class.getName() + RequestScoped.class.getName()));
+        assertTrue(ContextLifecycleEventsObserver.EVENTS.contains(Initialized.class.getName() + SessionScoped.class.getName()));
+    }
+
+    @AfterAll
+    public static void afterAll() {
+        // At this time @Destroyed from the previous test method should be fired
+        assertTrue(ContextLifecycleEventsObserver.EVENTS.contains(Destroyed.class.getName() + RequestScoped.class.getName()));
+        assertTrue(ContextLifecycleEventsObserver.EVENTS.contains(Destroyed.class.getName() + SessionScoped.class.getName()));
+    }
+
+}