-
1. Re: Warp: alternative syntax
kpiwko Oct 25, 2012 2:51 PM (in response to lfryc)I'm afraid there is no way how to ensure that. Maybe we can reuse @InSequence ?
-
2. Re: Warp: alternative syntax
lfryc Oct 25, 2012 3:22 PM (in response to kpiwko)We could also do post-processing and add @InSequence automatically using APT (in case it will ensure ordering).
-
3. Re: Warp: alternative syntax
aslak Oct 27, 2012 7:12 AM (in response to lfryc)hmm.. looks a bit confusing to me at first.
It seems to force a new method when ever you want to 'move' to the container side.
-
4. Re: Warp: alternative syntax
dan.j.allen Nov 20, 2012 4:35 AM (in response to lfryc)I don't think annotated methods should be used for flow control. The @InSequence ensures order, but the dependency is on the system state not necessarily on sequential, handshake steps.
If you think you can find a way to make it work, then keep at it. I won't discourage you from experimenting. We should be careful to make the reader do too much wiring in his or her head, just something to keep in mind.
-
5. Re: Warp: alternative syntax
lfryc Nov 20, 2012 6:02 AM (in response to dan.j.allen)+1 the proposed syntax is not really step forward
The real problem which comes with anonymous classes is that some people does not like code structure it comes with it:
Is it space where JSFUnit really excelled and what is the ideal we should try to achieve.
-
6. Re: Warp: alternative syntax
aslak Nov 20, 2012 6:21 AM (in response to lfryc)There is nothing that forces anyone to use annonymous classes tho. In some cases it's just a lazy shortcut.
@Test public void testGlobalMessageIsIgnored() { // Warp.execute({ guardHttp(submitButton).click() }) Java8 closure? Warp.execute(new GuardedClick(submitButton)) .verify(new GlobalMessageBehavior()); assertEquals(input3, getFocusedElement()); } private static class GlobalMessageBehavior() { private static final long serialVersionUID = 1L; @BeforePhase(Phase.RENDER_RESPONSE) public void addGlobalMessage() { FacesContext context = FacesContext.getCurrentInstance(); context.addMessage(null, new FacesMessage("global message")); } @AfterPhase(Phase.RENDER_RESPONSE) public void verifyGlobalMessageIsIgnored() { FacesContext context = FacesContext.getCurrentInstance(); AbstractFocus component = bean.getComponent(); FocusRendererBase renderer = bean.getRenderer(); String candidates = renderer.getFocusCandidatesAsString(context, component); assertEquals("form", candidates); } }
Maybe a WebDriver Warp Function lib would help some. Atleast for the ClientActions.
Warp.execute(Client.clickGuarded(driver))
Warp.execute(Client.navigateTo(driver, indexPage))
-
7. Re: Warp: alternative syntax
lfryc Nov 20, 2012 8:01 AM (in response to aslak)The integration with WebDriver is tempting:
public class Warp { public static <T> T guard(T target) { ...} }
guard(driver).get(url); verify(new ServerAssertion() { ... }); guard(button).click(); verify(new ServerAssertion() { ... });
We should definitely make the API Java8 / closures compatible.
-
8. Re: Warp: alternative syntax
dan.j.allen Nov 20, 2012 3:01 PM (in response to lfryc)Now you are on to something. Having the option to separate the chaining of verify seems to reduce some of the clutter.
Personally, the nested classes don't throw me off...but perhaps it's because I'm used to it from the old days of SeamTest (which, btw, Warp leaves in the dust!)
Another alternative is to use Groovy for tests. Recall that Groovy now has a type-safe mode, so you get the best of both worlds: closures today and the feeling of type-safe Java. It's defintiely something worth looking into. Tests like this lend itself very well to a more flexible language.
But again, keep poking at it and see if you come up with an alternative that works well in pure Java.