It seems to me correct. What happens is the following: Weld finds two bean archives (one corresponds to target/test-classes, second one to target/classes). That's the reason of why you are seeing your output twice (two application contexts are initialized). The trick is how you define (enables) your alternative. You have it in your beans.xml which means the alternative is selected per bean archive (http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#declaring_selected_alternatives) and this won't work since Car is in the second bean archive. So just enable your alternative with @Priority annotation instead of beans.xml definition and it should work.
If you consider testing with Weld SE you can take a look at https://github.com/tremes/arquillian-container-se. It is used e.g in: https://github.com/weld/core/blob/master/environments/se/tests/src/test/java/org/jboss/weld/environment/se/test/implicit/ImplicitScanSmokeTest.java
|