Hi,

I've written a Junit Runner for Webbeans support in TestCases. The following features are supported:
 - TestCase class field injection
 - TestMethod arg injection
 - Producers / Observers in the TestCase seems to work without any extras..
 - 'Should' run in any EE/Servlet/SE enviroment (Only SE tested at the moment) 
 

The Runner tries to locate the appropriate BeanManager based on the following rules in order:
- Lookup "java:comp/BeanManager" via JNDI -> EE enviroment
- If success use that BeanManager. 
- Call CurrentManager.rootManager() -> Servlet enviroment / Previously initiated SE enviroment
- If success use that BeanManager. 
- Load class "org.jboss.webbeans.environment.se.StartMain" -> SE enviroment
- If success, initialize the enviroment using StartMain.main(new String[0]) and use CurrentManager.rootManager().

Overrides the default Junit TestMethod validation with a new set of rules:
- validatePublicVoid (default validatePublicVoidNoArgs)
- validateBindingTypeParameters (only arguments annotated with a BindingType allowed)

Overrides the createTest method to inject TestCase fields:
pesudo: for each Field "annotated with a BindingType" set getInstanceByType
Overrides methodInvoker to inject TestMethod args:
pesudo: for each Arg getInstanceByType


Annotate the TestCase with @RunWith(Webbeans.class) and one should be good to go..

If interested, the code with TestCase example can be found at: 
http://pastebin.com/m66ad1894


--
--
Aslak Knutsen; +47 952 38 791; fax +47 22 33 60 24
Kongens gate 14; Boks 805 Sentrum, 0104 Oslo;
http://www.conduct.no; mailto:aslak@conduct.no

Conduct AS - Professional Open Source Services
- Red Hat/JBoss Premier System Integrator
- Pentaho Preferred Integration Partner
- Atlassian Technology Partner