struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <lukaszlen...@apache.org>
Subject Re: Examples app
Date Wed, 05 Sep 2012 10:53:00 GMT
2012/9/4 Dave Newton <davelnewton@gmail.com>:
> I think the coolest would be to have some BDD in there, like with easyb/etc.

I have no experiences with BDD/easyb, some example ?

> It can drive JWebUnit (IIRC, or HtmlUnit), can be run from Maven, and is
> easy to write.

Yeah, no needs to run a web browser and so on, but that's wrong :/

Anyway, I was able to add a simple integration test to Blank Webapp,
it looks like below, WDYT? Is it the right direction ?

public class HelloWorldIntegrationTest {

    public static final int PORT = 8090;

    @Before
    public void setUp() throws Exception {
        Server server = new Server(PORT);
        WebAppContext handler = new WebAppContext("src/main/webapp",
"/struts2-blank");
        server.setHandler(handler);
        server.start();

        JWebUnit.setBaseUrl("http://localhost:" + PORT + "/struts2-blank/");
    }

    @Test
    public void testIndex() throws Exception {
        // when
        JWebUnit.beginAt("index.action");

        // then
        JWebUnit.assertResponseCode(200);
        JWebUnit.assertTitleEquals("Struts is up and running ...");
        JWebUnit.assertLinkPresentWithExactText("English");
        JWebUnit.assertLinkPresentWithExactText("Espanol");
    }

}


Regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message