This content has been marked as final.
Show 2 replies
-
1. Re: How to pass parameters with ComponentTest.invokeMethod
chawax Jan 16, 2008 8:07 AM (in response to chawax)Well I read that you can't use parameters with invokeMethod. So I tried with Expressions.createMethodExpression :
MethodExpression<Employe> me = Expressions.instance().createMethodExpression( "#{coreServiceEmploye.saveEmploye(employe)}", Employe.class, new Class[]{Employe.class}); employe = me.invoke(employe);
But still the same problem, employe parameter is null in coreServiceEmploye.saveEmploye method. I really can't understand why. Anyone has an idea ? -
2. Re: How to pass parameters with ComponentTest.invokeMethod
chawax Jan 17, 2008 5:47 AM (in response to chawax)I gave up using reflection to call Seam component and used getInstance() method instead to get the Seam component and then call its methods as usual. So now it looks like this :
@org.testng.annotations.Test ( public void testEmploye() throws Exception { new ComponentTest() { @Override protected void testComponents() throws Exception { CoreServiceEmployeLocal serviceEmploye = (CoreServiceEmployeLocal) getInstance("coreServiceEmploye"); Employe employe = new Employe(); employe.setMatricule("000001"); employe.setNom("nom"); employe.setPrenom("prenom"); employe = serviceEmploye.saveEmploye(employe); assert employe.getId() != null; } }.run(); }
It looks more simple to me, but are there things that will not work testing this way ? What is the interest of using invokeMethod() then ?