Oops. This doesn't work yet because the java HTTP object doesn't seem to send along the Host field on a HTTP GET so c2.com's web server can route the request to the correct virtual server. Bummer.
For now we look around Google instead.
fit.ActionFixture | ||
start | eg.Page | |
enter | location | http://google.com |
check | title | |
enter | link | Jobs |
check | title | About Google |
enter | link | Press |
enter java.lang.NullPointerException at eg.Page.link(Page.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at fit.ActionFixture.enter(ActionFixture.java:36) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at fit.ActionFixture.doCells(ActionFixture.java:19) at fit.Fixture.doRow(Fixture.java:94) at fit.Fixture.doRows(Fixture.java:88) at fit.Fixture.doTable(Fixture.java:82) at fit.Fixture.doTables(Fixture.java:72) at fit.FileRunner.process(FileRunner.java:29) at fit.FileRunner.run(FileRunner.java:22) at fit.FileRunner.main(FileRunner.java:17) | link | Review |
check | title | Google Press Room expected Google Press Center actual |
Here is what this page is suppose to look like.
See the source.Java gurus suggest that the problem is related to weak libraries in the kaffe implementation and that either sun or ibm jvm will make problems go away.
Testing server side java ...
fit.ActionFixture | ||
start | eg.Page | |
enter | location | http://fit.c2.com |
check | title | Wiki: Welcome Visitors |
I wrote this example to help get WilkesJoiner and JimWeaver started with our framework. They didn't seem to need it. While I'm still debuging they are distributing a similar fixture exploiting their jwebunit facade to HttpUnit. Nice work guys. -- WardCunningham
In this example we will use a fixture to look around the web. Developers of web applications often get the idea that this is a good universal interface to their programs. We don't think so. You are far better off testing your server site objects from fixturing running on the server. But you will probably want to do some testing over http so we show here how it can be done.
You can run this test on the fit.c2.com server with the usual run.cgi command. This will have c2.com acting as a client on your behalf.
We use actions to start eg.Page, our web browser like fixture. We can enter location, a web address, or link, which follows a link on the page to a new location. When we enter a link, the fixture searches the current page for an anchor that starts with the entered text. You only have to enter enough to be unique. Then it retrieves that page.
fit.ActionFixture | ||
start | eg.Page | |
enter | location | http://fit.c2.com |
check | title | Wiki: Welcome Visitors |
enter | link | Example |
check | title | Wiki: Example Tests |
enter | link | Simple |
check | title | Wiki: Simple Example |
The eg.Page fixture is also a row fixture. Here we use it that way to check on the rows of the SimpleExample.
eg.Page | |
numerator() | denominator() |
1000 | 10 |
1000 | 7 |
1000 missing | 0 |
1000 missing | .001 |
-1000 | 10 |
0 missing | 0 |
1000 surplus | .00001 |
4195835 surplus | 3145729 |
We left out the pentium bug values on purpose just so you would know we really are reading from that page. We will follow the pentium bug reference just to show that we can read from other servers.
fit.ActionFixture | ||
enter | link | http://www.cs.earlham |
check | title | Bugs in the Intel Microprocessors |
enter | link | Main |
enter | link | Dusko |
enter | link | web |
check | title | WebDB - Version 3.1 expected WebDB - Version 3.3 actual |
There are a couple of things that are not quite right about this example.
It would be neat to see some tests of an XML interface. Google has one.