You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Roy van Rijn <ro...@gmail.com> on 2007/08/14 17:21:29 UTC

Wicket testing HTML

Hi all,

I've started working with Wicket about a week ago. I'm now creating
tests for my wicket page. The things I'm currently testing is this:

	public void test() throws ServletException {
		TestService service = new TestServiceImpl();

		AnnotApplicationContextMock appctx = new AnnotApplicationContextMock();
		appctx.putBean("testService", service);

		WicketTester app = new WicketTester();
		app.addComponentInstantiationListener(new
SpringComponentInjector(app, appctx));
		Page loginPage = app.startPage(new login());
		
		app.assertRenderedPage(login.class);
		app.assertComponent("helloworld", Label.class);
		app.assertLabel("helloworld","world!");
	}

This works like a charm, it checks the WebPage and even checks the
value of the label. But my problem is this, when I mess something up
in the HTML (for example </bdoy> instead of </body>) it still gives
jUnit the green light. But when I check this
System.out.println(app.getServletResponse().getDocument()); the result
is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Unexpected RuntimeException</title>
<style type="text/css">
body {margin-left : 2em;font-family: 'Lucida Sans', 'Helvetica',
'Sans-serif', 'sans';font-size: 9pt;line-height: 1.8em;}
h1,h2,h3,h4,h5,h6,h7,h8 {color: #E9601A;}
h1 {font-size : 1.5em;}
h2 {font-size : 1.2em;}
---ETC---

So the unit-test shows everything is fine while Wicket knows something
went wrong. Is there any way to check if Wicket created the right
webpage?

It isn't very hard to check the generated <title> and see if it equals
Unexpected RuntimeException... but Wicket should have a more elegant
way right?

Roy (yoR)

ps. First post, be gentle ;-)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org