If you can't read please download the document
Upload
others
View
9
Download
0
Embed Size (px)
Citation preview
Java Test Runner
http://jtrunner.sourceforge.netFrancesco Russo
Testing matters...
What is an error?
"Error is a difference between the desired and actual behavior or performance of a system or object"
But testing has different flavors
Behavioral
Integration
System & Stress
User acceptance
... and more
JTR is...
... a dynamic testing tool suitable for:
• integration / system testing• behavioral testing
"How can JTR help me?"
JTR lets you (stress-)test
Standard Java™ classes
JTR lets you (stress-)test
Standard Java™ classes
J2EE 1.4 Session Beans
JTR lets you (stress-)test
Standard Java™ classes
J2EE 1.4 Session Beans
JEE 5 Session Beans
JTR lets you (stress-)test
Standard Java™ classes
J2EE 1.4 Session Beans
JEE 5 Session Beans
Web Services
JTR lets you (stress-)test
Standard Java™ classes
J2EE 1.4 Session Beans
JEE 5 Session Beans
Web Services
JMS applications
Parameters matter
JTR adopts Inversion of Control
Push... ... not pull!
Parameterization happens with...
Fixed values
Parameterization happens with...
Fixed valuesStatistically
generated values
Parameterization happens with...
Fixed valuesStatistically
generated values
Scripted values
A simple example
A really simple JTR runner...package jtr.test.fosdem;
import jtr.runners.AbstractRunner;import junit.framework.Assert;
public class FosdemRunner extends AbstractRunner { @Override public void test() throws Throwable { Assert.assertEquals(1978, hardcodedParameter); addMessage("Hardcoded parameter is: "+hardcodedParameter); addMessage("\nGaussian parameter is: "+gaussianParameter); Assert.assertEquals("Hello FOSDEM", scriptedParameter); addMessage("\nScripted parameter is: "+scriptedParameter); } private int hardcodedParameter; private double gaussianParameter; private String scriptedParameter;}
package jtr.test.fosdem;
import jtr.runners.AbstractRunner;import junit.framework.Assert;
public class FosdemRunner extends AbstractRunner { @Override public void test() throws Throwable { Assert.assertEquals(1978, hardcodedParameter); addMessage("Hardcoded parameter is: "+hardcodedParameter); addMessage("\nGaussian parameter is: "+gaussianParameter); Assert.assertEquals("Hello FOSDEM", scriptedParameter); addMessage("\nScripted parameter is: "+scriptedParameter); } private int hardcodedParameter; private double gaussianParameter; private String scriptedParameter;}
Inherit useful behaviors
A really simple JTR runner...
package jtr.test.fosdem;
import jtr.runners.AbstractRunner;import junit.framework.Assert;
public class FosdemRunner extends AbstractRunner { @Override public void test() throws Throwable { Assert.assertEquals(1978, hardcodedParameter); addMessage("Hardcoded parameter is: "+hardcodedParameter); addMessage("\nGaussian parameter is: "+gaussianParameter); Assert.assertEquals("Hello FOSDEM", scriptedParameter); addMessage("\nScripted parameter is: "+scriptedParameter); } private int hardcodedParameter; private double gaussianParameter; private String scriptedParameter;}
Your testing logic starts from here
A really simple JTR runner...
package jtr.test.fosdem;
import jtr.runners.AbstractRunner;import junit.framework.Assert;
public class FosdemRunner extends AbstractRunner { @Override public void test() throws Throwable { Assert.assertEquals(1978, hardcodedParameter); addMessage("Hardcoded parameter is: "+hardcodedParameter); addMessage("\nGaussian parameter is: "+gaussianParameter); Assert.assertEquals("Hello FOSDEM", scriptedParameter); addMessage("\nScripted parameter is: "+scriptedParameter); } private int hardcodedParameter; private double gaussianParameter; private String scriptedParameter;}
Leverage on JUnit assertion APIs
A really simple JTR runner...
package jtr.test.fosdem;
import jtr.runners.AbstractRunner;import junit.framework.Assert;
public class FosdemRunner extends AbstractRunner { @Override public void test() throws Throwable { Assert.assertEquals(1978, hardcodedParameter); addMessage("Hardcoded parameter is: "+hardcodedParameter); addMessage("\nGaussian parameter is: "+gaussianParameter); Assert.assertEquals("Hello FOSDEM", scriptedParameter); addMessage("\nScripted parameter is: "+scriptedParameter); } private int hardcodedParameter; private double gaussianParameter; private String scriptedParameter;}
Give end-users a feed-back for later inspection
A really simple JTR runner...
package jtr.test.fosdem;
import jtr.runners.AbstractRunner;import junit.framework.Assert;
public class FosdemRunner extends AbstractRunner { @Override public void test() throws Throwable { Assert.assertEquals(1978, hardcodedParameter); addMessage("Hardcoded parameter is: "+hardcodedParameter); addMessage("\nGaussian parameter is: "+gaussianParameter); Assert.assertEquals("Hello FOSDEM", scriptedParameter); addMessage("\nScripted parameter is: "+scriptedParameter); } private int hardcodedParameter; private double gaussianParameter; private String scriptedParameter;}
Instance properties... any mutator method is required!
A really simple JTR runner...
... and its jtr.xml
jtr.test.fosdem.FosdemRunner5indexed
... and its jtr.xml
jtr.test.fosdem.FosdemRunner5indexed
how many times to run
... and its jtr.xml
jtr.test.fosdem.FosdemRunner5indexed
the runner that has to run
... and its jtr.xml
jtr.test.fosdem.FosdemRunner5indexed
how many instances?
... and its jtr.xml
jtr.test.fosdem.FosdemRunner5indexed
a fixed input value
... and its jtr.xml
jtr.test.fosdem.FosdemRunner5indexed
a statistical one...
... and its jtr.xml
jtr.test.fosdem.FosdemRunner5indexed
... and a scripted one
... and its jtr.xml
jtr.test.fosdem.FosdemRunner5indexed
and here is the script
Let's run it!Let's run it!
Write once, run many and anywhere
Write once, run many and anywhere
Declarative concurrent test
execution
Write once, run many and anywhere
Declarative concurrent test
execution
Declarative distributed test
execution
Declarative distribution
Simply add the following snippet to the jtr.xml file:
For further details, please check the on-line users' guide.
Some definitions
• JTR Active Node runs the JTR runtime, our Runners and 3rd party libraries
• JTR Passive Node only runs the JTR runtime
JTR Distributed Testing at work
JTR active node runners and 3rd party
libraries
JTR passive node only the JTR runtime
Step one is the distribution of the jtr.xml configuration
JTR active node runners and 3rd party
libraries
JTR passive node only the JTR runtime
Missing class/resource request
class/resource response
JTR Distributed Testing at work
Let's run it!Let's run it again!
Thusno manual deployments
overpassive-nodes
Firewalls?!
Not a problem
What if I'm a JUnit fan?
JTR 5smoothly integrates
JUnit 4
and much more
• Ant integration• headless testing• basic reporting (Excel exporting)
Time is over...
Salvador Dalí. (Spanish, 1904-1989). The Persistence of Memory. 1931. Oil on canvas, 9 1/2 x 13" (24.1 x 33 cm). Given anonymously. © 2009 Salvador Dalí, Gala-Salvador Dalí Foundation/Artists Rights Society (ARS), New York
more on the website!http://jtrunner.sourceforge.net
THANK YOU!
Francesco [email protected]