+ All Categories
Home > Software > Java2 days 2013-j-treg

Java2 days 2013-j-treg

Date post: 04-Nov-2014
Category:
Upload: mani-sarkar
View: 112 times
Download: 0 times
Share this document with a friend
Description:
A JTreg presentation given at Java2Days in 2013. JTreg is the Java Test Harness for OpenJDK.
Popular Tags:
15
JTreg Martin Toshev Ivan St. Ivanov Mani Sarkar Dmitry Alexandrov
Transcript
Page 1: Java2 days 2013-j-treg

JTreg

Martin ToshevIvan St. Ivanov

Mani SarkarDmitry Alexandrov

Page 2: Java2 days 2013-j-treg

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…)

Page 3: Java2 days 2013-j-treg

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

Page 4: Java2 days 2013-j-treg

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");

}}

}

Page 5: Java2 days 2013-j-treg

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

Page 6: Java2 days 2013-j-treg

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>*

Page 7: Java2 days 2013-j-treg

Jtreg – test description

@run – optional tag:– Manual:• @run applet/manual• @run main/manual• @run shell/ manual

– Negative tests:• @run main/fail

Page 8: Java2 days 2013-j-treg

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

Page 9: Java2 days 2013-j-treg

Jtreg – JDK-related options

• Run test concurrently– -conc:N | -concurrency: N– Cannot be used with –samevm

• Timeouts– -timeout:N | -timeoutFactor:N

Page 10: Java2 days 2013-j-treg

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

Page 11: Java2 days 2013-j-treg

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>

Page 12: Java2 days 2013-j-treg

Jtreg – reporting the results

• Different report and work directory– -r: | -reportDir:<dir> – -w: | -workDir:<dir>

• Report as xml– -xml

Page 13: Java2 days 2013-j-treg

Jtreg – running tests

>jtreg –verbose:summary –jdk:{PRODUCT} <other options> test.java

Jtreport/html/report.htmlJtreport/text/summary.txtJtwork/test.jtr

Page 14: Java2 days 2013-j-treg

Jtreg – running tests

… or use make tests

Page 15: Java2 days 2013-j-treg

Now let’s have fun!!!


Recommended