[webbeans-dev] Webbeans Junit Runner

Pete Muir pmuir at redhat.com
Mon Aug 3 13:27:07 EDT 2009


Hi Aslak,

I think this looks excellent, and I really like most of the feature  
set. I'm going to lay out my ideas about what I would like to see in  
the test harness. I think we can split the discussion (and module)  
into two parts:

1) Bootstrapper - this could either be a standlone (mock out the  
interaction with other frameworks such as EJB) full EE env, Servlet  
env or SE env OR incontainer (full EE env or Servlet env). This builds  
on the work we did with the Web Beans test suites and the JBoss Test  
Harness. This part is bound tightly to Web Beans APIs, and is not  
portable to other CDI implementations

2) Runner - supports injection, and depends only on the CDI API, which  
is what you have written below.

We should definitely get this integrated into Web Beans Extensions.  
Can you send me an email and I will support out commit access for you?  
Are you interested in working on the bootstrapper too?

We need to add in:

* Testcases to ensure the Runner is executing correctly
* TestNG support
* A short documentation for the ref guide
* An example

Great stuff,

Pete

On 29 Jul 2009, at 12:37, Aslak Knutsen wrote:

> 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 at conduct.no
>
> Conduct AS - Professional Open Source Services
> - Red Hat/JBoss Premier System Integrator
> - Pentaho Preferred Integration Partner
> - Atlassian Technology Partner
> _______________________________________________
> webbeans-dev mailing list
> webbeans-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/webbeans-dev




More information about the weld-dev mailing list