-
Notifications
You must be signed in to change notification settings - Fork 5
/
testing-framework.html
109 lines (99 loc) · 6.24 KB
/
testing-framework.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testing Framework</title>
</head>
<body>
<div class="instructions">
<h1>Testing Framework</h1>
<h3>General information</h3>
There are different kind of tests:
<ul>
<li><strong>junit</strong>: To test specific functionality of certain java components/classes see <a href="http://junit.org/">http://junit.org/</a></li>
<li><strong>htmlunit</strong>: To test the web pages (simulating user interaction) see <a href="http://htmlunit.sourceforge.net/">http://htmlunit.sourceforge.net/</a></li>
<li><strong>Canoo</strong>: To test the web pages (simulating user interaction) see <a href="http://webtest.canoo.com/">http://webtest.canoo.com</a></li>
<li><strong>JMeter</strong>: To load test web applications (simulating user interaction) see <a href="http://jakarta.apache.org/jmeter/">http://jakarta.apache.org/jmeter/</a></li>
</ul>
<h3>How to run the tests</h3>
<p>After downloading the Yanel source (either via <a href="../../download/source-repository.html">Git</a> or as <a href="../download/index.html">snapshot</a>) one can run the tests all at once (as we do it for example with <a href="http://jenkins-ci.org/">Jenkins</a>) or run the various tests individually.</p>
<p>If you want to run all at once (including build and start of Yanel), then execute the shell script</p>
<pre>./src/build/targets/continuous-integration/reCI 8080 8443 8005 8009 /home/michi/local/canoo-webtest-3.0-R_1758
</pre>
whereas please make sure to have <a href="http://webtest.canoo.com">Canoo webtests</a> installed.
<p> </p>
<p>If you want to run the tests individually, then it's necessary to build and start yanel before running the tests.</p>
<p><strong>IMPORTANT:</strong> If you want to run the htmlunit tests, you have to start tomcat and configure the host and url inside</p>
<pre>$YANEL_HOME/src/test/htmlunit/local.htmlunit-properties.xml
</pre>
<p>One can also set realm specific variables, like for example the realm prefix:</p>
<pre>
<my-prefix>my-realm</my-prefix>
</pre>
<p>which then can be retrieved via the Java Test class:</p>
<pre>
protected void setUp() throws Exception {
this.testName = "My Test";
super.setUp();
// INFO: Overwrite htmlunit configuration (src/test/htmlunit/local.htmlunit-properties.xml) and add element <my-realm-prefix>
REALM_PREFIX = config.getString("htmlunit.my-realm-prefix");
}
</pre>
<p> </p>
<p>Then execute in $YANEL_HOME:</p>
<pre>./build.sh test
</pre>
<p> </p>
<p>To run single tests standalone:</p>
<pre>
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
</pre>
<p> </p>
<p>To run Yanel specific Canoo webtests (including junit and htmlunit):</p>
<pre>./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=
</pre>
<p> </p>
<p>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.</p>
<p>Some Canoo web-tests are located at</p>
<pre>src/realms/use-cases/yanel/src/test/canoo/
src/realms/yanel-website/src/test/canoo/
</pre>
whereas also see the README.txt files within these directories.
<p> </p>
<p>To run realm specific Canoo webtests</p>
<pre>./build.sh -f src/realms/yanel-website/src/test/canoo/build.xml
</pre>
or to run a specific target
<pre>./build.sh -f src/realms/yanel-website/src/test/canoo/build.xml MY_TARGET_NAME
</pre>
<p> </p>
<p>whereas make sure to configure the properties within the realm first, e.g.</p>
<pre>src/realms/yanel-website/src/test/canoo/build.properties
src/realms/yanel-website/src/test/canoo/local.build.properties<br /></pre>
<p>To run JMeter tests, use the "jmeter" target:</p>
<pre>./build.sh [-f path/to/build.xml] jmeter<br /></pre>
<p> </p>
<h3>Debugging and Logging</h3>
<p>
The log level can be set inside <code>src/test/htmlunit/local.htmlunit-properties.xml</code> (<code>debugLevel</code>), whereas the log messages are written to standard output. The log is setup inside <code>src/test/htmlunit/org/wyona/yanel/htmlunit/AbstractHtmlUnitTest.java</code>.
</p>
<p> </p>
<h3>How to write tests</h3>
<p>Where to place core tests: <br />$YANEL_HOME/src/test/junit/ <br />$YANEL_HOME/src/test/htmlunit/ <br /><br />Where to place resource tests: <br />$YANEL_HOME/src/resources/MYRESOURCE/src/test/junit/ <br />$YANEL_HOME/src/resources/MYRESOURCE/src/test/htmlunit/</p>
<p>Choose the name of the class according to the following convention:</p>
<p>*Test.java e.g. MyResourceTest.java for junit tests</p>
<p>*WebTest.java e.g. MyResourceWebTest.java for htmlunit tests</p>
<p>The tests which adhere to these conventions will be executed automatically by the testing framework.</p>
<p>Have a look at the existing tests to see how it works, e.g. in the xml resource.</p>
<p>You can find more example htmlunit tests at: <a href="https://github.com/wyona/lenya/tree/master/htmlunit">https://github.com/wyona/lenya/tree/master/htmlunit</a> (Username:anonymous Password: anonymous).</p>
<p>For writing JMeter tests, see the <a href="jmeter.html">JMeter page</a>.</p>
<h3>Misc</h3>
<p>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 <code>/Library/Java/Extensions</code> (also see <a href="http://blog.jonasbandi.net/2009/06/running-canoo-webtest-30-on-os-x.html">http://blog.jonasbandi.net/2009/06/running-canoo-webtest-30-on-os-x.html</a>).</p>
<a name="continuous-integration"> </a>
<h3>Continuous Integration / Delivery /Deployment</h3>
<p>Please see <a href="http://continuous.wyona.com/en/projects/yanel/index.html">http://continuous.wyona.com/en/projects/yanel/index.html</a> regarding code modifications and associated tests.</p>
</div>
</body>
</html>