Testing Framework

General information

There are different kind of tests:

How to run the tests

After downloading the Yanel source (either via SVN or as snapshot) one can run the tests all at once (as we do it within Hudson) or run the various tests individually.

If you want to run all at once (including build and start of Yanel), then execute the shell script

./src/build/targets/continuous-integration/reCI 8080 8443 8005 8009 /home/michi/local/canoo-webtest-3.0-R_1758
whereas please make sure to have Canoo webtests installed.

 

If you want to run the tests individually, then it's necessary to build and start yanel before running the tests.

IMPORTANT: If you want to run the htmlunit tests, you have to start tomcat and configure the host and url in

$YANEL_HOME/src/test/htmlunit/local.htmlunit-properties.xml

 

Then execute in $YANEL_HOME:

./build.sh test

 

To run single tests standalone:

cd $YANEL_HOME
./build.sh -f src/test/build.xml junit -Dtest.class.name=org.wyona.yanel.impl.map.MapImplTest
./build.sh -f src/test/build.xml htmlunit -Dtest.class.name=org.wyona.yanel.htmlunit.yanelwebsite.SimpleWebTest

 

To run Yanel specific Canoo webtests (including junit and htmlunit):

./build.sh test -Dwebtest.home.dir=/usr/local/canoo-webtest-3.0-R_1758 -Dwebtest.config.host=localhost -Dwebtest.config.protocol=http -Dwebtest.config.port=8080 -Dheadless=

 

whereas if the global property 'headless' is set, then also the Canoo property 'wt.headless' is set within src/build/targets/test.xml, which means no monitor is displayed and no browser is opened to display the Canoo results.

Some Canoo web-tests are located at

src/realms/use-cases/yanel/src/test/canoo/
src/realms/yanel-website/src/test/canoo/
whereas also see the README.txt files within these directories.

 

To run realm specific Canoo webtests

./build.sh -f src/realms/yanel-website/src/test/canoo/build.xml
or to run a specific target
./build.sh -f src/realms/yanel-website/src/test/canoo/build.xml MY_TARGET_NAME

 

whereas make sure to configure the properties within the realm first, e.g.

src/realms/yanel-website/src/test/canoo/build.properties
src/realms/yanel-website/src/test/canoo/local.build.properties

To run JMeter tests, use the "jmeter" target:

./build.sh [-f path/to/build.xml] jmeter

 

How to write tests

Where to place core tests:
$YANEL_HOME/src/test/junit/
$YANEL_HOME/src/test/htmlunit/

Where to place resource tests:
$YANEL_HOME/src/resources/MYRESOURCE/src/test/junit/
$YANEL_HOME/src/resources/MYRESOURCE/src/test/htmlunit/

Choose the name of the class according to the following convention:

*Test.java e.g. MyResourceTest.java for junit tests

*WebTest.java e.g. MyResourceWebTest.java for htmlunit tests

The tests which adhere to these conventions will be executed automatically by the testing framework.

Have a look at the existing tests to see how it works, e.g. in the xml resource.

You can find more example htmlunit tests at: http://svn.wyona.com/repos/public/lenya/htmlunit/ (Username:anonymous Password: anonymous).

For writing JMeter tests, see the JMeter page.

Misc

In the case of Mac OS X (at least Snow Leopard) and Java 1.6 one needs to add xalan-2.7.0.jar to the directory /Library/Java/Extensions (also see http://blog.jonasbandi.net/2009/06/running-canoo-webtest-30-on-os-x.html).



Your comments are much appreciated

Is the content of this page unclear or you think it could be improved? Please add a comment and we will try to improve it accordingly.