SlideShare a Scribd company logo
JTreg 
Martin Toshev 
Ivan St. Ivanov 
Mani Sarkar 
Dmitry 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 vms 
Modes 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.html 
Jtreport/text/summary.txt 
Jtwork/test.jtr
Jtreg – running tests 
… or use make tests
Now let’s have fun!!!

More Related Content

PPT
Testing And Drupal
ODP
Good Practices On Test Automation
PPT
Mxunit
PDF
Unit testing Ch. 13 of Programming Ruby
PPT
xUnit Style Database Testing
PPTX
PPTX
TestNG Session presented in PB
PPT
JavaScript Unit Testing
Testing And Drupal
Good Practices On Test Automation
Mxunit
Unit testing Ch. 13 of Programming Ruby
xUnit Style Database Testing
TestNG Session presented in PB
JavaScript Unit Testing

What's hot (20)

PDF
All about unit testing using (power) mock
PPTX
JProfiler8 @ OVIRT
PPTX
Power mock
PPTX
Chapter v(error)
PPTX
PPTX
Kill the mutants and test your tests - Roy van Rijn
PDF
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
PDF
TestNG Annotations in Selenium | Edureka
PDF
Spock pres
PPTX
J unit스터디슬라이드
PPTX
Unit Testing with Python
PDF
Mutation Testing with PIT (Booster 2014, 2014-MAR-13)
PPT
Mockito with a hint of PowerMock
PPT
Code Review In Testing View
PDF
Gatling - Bordeaux JUG
PPTX
Testing Spring Boot application in post-JUnit 4 world
PPTX
Pi j4.2 software-reliability
PDF
Robot Framework Dos And Don'ts
PDF
Mocking in Java with Mockito
PPTX
Whitebox testing of Spring Boot applications
All about unit testing using (power) mock
JProfiler8 @ OVIRT
Power mock
Chapter v(error)
Kill the mutants and test your tests - Roy van Rijn
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TestNG Annotations in Selenium | Edureka
Spock pres
J unit스터디슬라이드
Unit Testing with Python
Mutation Testing with PIT (Booster 2014, 2014-MAR-13)
Mockito with a hint of PowerMock
Code Review In Testing View
Gatling - Bordeaux JUG
Testing Spring Boot application in post-JUnit 4 world
Pi j4.2 software-reliability
Robot Framework Dos And Don'ts
Mocking in Java with Mockito
Whitebox testing of Spring Boot applications
Ad

More from Mani Sarkar (19)

PDF
How to contribute to Adopt OpenJDK?
PDF
Java 9 / Jigsaw - AJUG/VJUG session
PDF
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
PDF
Cli in the browser
PDF
Theory of constraints
PDF
Kanban kata
PDF
Refactoring developer habits
PDF
Essential technical skills
PDF
How is Java / JVM built ? Back then and now...
PDF
How is Java / JVM built ? Adopt OpenJDK is your answer !
PDF
Adopt OpenJDK the past, the present & the future
PDF
Adopt OpenJDK presentation (slide deck)
PDF
Adopt OpenJDK, Betterrev blind ignite presentation
PDF
Fosdem2014 fromwebrevtobetterrevbryantsarkar-140203131215-phpapp02
PPTX
Java2 days 2013-lambda
PPTX
Ljc conf open jdk betterrev bof
PPTX
Sonar qube to impove code quality
PDF
History of java
PDF
Leaning on the two Ts
How to contribute to Adopt OpenJDK?
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Cli in the browser
Theory of constraints
Kanban kata
Refactoring developer habits
Essential technical skills
How is Java / JVM built ? Back then and now...
How is Java / JVM built ? Adopt OpenJDK is your answer !
Adopt OpenJDK the past, the present & the future
Adopt OpenJDK presentation (slide deck)
Adopt OpenJDK, Betterrev blind ignite presentation
Fosdem2014 fromwebrevtobetterrevbryantsarkar-140203131215-phpapp02
Java2 days 2013-lambda
Ljc conf open jdk betterrev bof
Sonar qube to impove code quality
History of java
Leaning on the two Ts
Ad

Recently uploaded (20)

PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
ai tools demonstartion for schools and inter college
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
history of c programming in notes for students .pptx
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Nekopoi APK 2025 free lastest update
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Transform Your Business with a Software ERP System
PPTX
Introduction to Artificial Intelligence
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Essential Infomation Tech presentation.pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
PTS Company Brochure 2025 (1).pdf.......
ai tools demonstartion for schools and inter college
VVF-Customer-Presentation2025-Ver1.9.pptx
history of c programming in notes for students .pptx
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Nekopoi APK 2025 free lastest update
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
How to Migrate SBCGlobal Email to Yahoo Easily
Reimagine Home Health with the Power of Agentic AI​
Transform Your Business with a Software ERP System
Introduction to Artificial Intelligence
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Essential Infomation Tech presentation.pptx
Odoo Companies in India – Driving Business Transformation.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Which alternative to Crystal Reports is best for small or large businesses.pdf

Java2 days 2013-j-treg

  • 1. JTreg Martin Toshev Ivan St. Ivanov Mani Sarkar Dmitry Alexandrov
  • 2. 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…)
  • 3. 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
  • 4. 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"); } } }
  • 5. 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
  • 6. 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>*
  • 7. Jtreg – test description @run – optional tag: – Manual: • @run applet/manual • @run main/manual • @run shell/ manual – Negative tests: • @run main/fail
  • 8. 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
  • 9. Jtreg – JDK-related options • Run test concurrently – -conc:N | -concurrency: N – Cannot be used with –samevm • Timeouts – -timeout:N | -timeoutFactor:N
  • 10. 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 vms Modes can be specified directly in the source file: – @run main/othervm/timeout=300
  • 11. 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>
  • 12. Jtreg – reporting the results • Different report and work directory – -r: | -reportDir:<dir> – -w: | -workDir:<dir> • Report as xml – -xml
  • 13. Jtreg – running tests >jtreg –verbose:summary –jdk:{PRODUCT} <other options> test.java Jtreport/html/report.html Jtreport/text/summary.txt Jtwork/test.jtr
  • 14. Jtreg – running tests … or use make tests