Date post: | 04-Nov-2014 |
Category: |
Software |
Upload: | mani-sarkar |
View: | 112 times |
Download: | 0 times |
JTreg
Martin ToshevIvan St. Ivanov
Mani SarkarDmitry Alexandrov
Jtreg – test cases
• A test case is:– Java program with main method– An applet– Shell script (bourne shell)
• Jtreg supports TestNG– Via annotation– TEST.properties (demo later…)
Jtreg – test cases
• Pass criteria:– If test fails, testcase should throw an exception– If it succeeds, testcase should return normally• Avoid catching Throwable, Exception or Error
Jtreg – test cases
• Example:
/* @test * @summary StringBuffer.isEmpty(); * @run main IsEmptyTest */
public class IsEmptyTest {public static void main(String[] args) {
StringBuffer buffer = new StringBuffer();
if (!buffer.isEmpty()) {throw new RuntimeException("StringBuffer isEmpty on new object failed");
}}
}
Jtreg – test description
@test – defines a test. Mandatory.@run – tells how to perform a test.@summary – text description.@library – reference library source files.@build – compile class or library before running
test
Jtreg – test description
@bug – bug number reference@key – keywords
• Shorthands:– @build <classname>+ == @run build <classname>+– @clean <classname>+ == @run clean <classname>+– @compile<option>* <arg>+ == @run
compile<option>* <arg>+– @ignore <word>* == @run ignore <word>*
Jtreg – test description
@run – optional tag:– Manual:• @run applet/manual• @run main/manual• @run shell/ manual
– Negative tests:• @run main/fail
Jtreg – testrun and execution
• To pass JVM options for tests:– -vmoption | -vmoptions– Many common JVM options (like –server, -d64..)
are supported directly• Specified JDK:– -testjdk:<java.home>, -jdk:<java.home>– -compilejdk:<java.home>
• Java options– -javaoption | -javaoptions
Jtreg – JDK-related options
• Run test concurrently– -conc:N | -concurrency: N– Cannot be used with –samevm
• Timeouts– -timeout:N | -timeoutFactor:N
Jtreg – test mode options
-othervm : Run every test in own vm-samevm : Run all tests in the same vm as the
harness-agentvm : use pool of reusable vmsModes can be specified directly in the source
file:– @run main/othervm/timeout=300
Jtreg – test selection options
• To execute tests:– -exclude:ProblemList.txt– ProblemList.txt contains list of known failing tests
• Select specific tests:– -a | -automatic – -m | -manual– -k:<keyword>
Jtreg – reporting the results
• Different report and work directory– -r: | -reportDir:<dir> – -w: | -workDir:<dir>
• Report as xml– -xml
Jtreg – running tests
>jtreg –verbose:summary –jdk:{PRODUCT} <other options> test.java
Jtreport/html/report.htmlJtreport/text/summary.txtJtwork/test.jtr
Jtreg – running tests
… or use make tests
Now let’s have fun!!!