Tuesday, November 18, 2014

New Eclipse JUnit Feature: Run Subtrees of Tests Individually, e.g. from Parameterized Tests

In Eclipse, the JUnit view nicely visualizes execution status and results of JUnit tests. JUnit tests usually are Java classes with test methods or Java classes annotated with @SuiteClasses, which compose multiple other test classes or suites.

But JUnit is more powerful than that. It allows you to implement custom test runners. Those test runners are responsible for creating a tree structure of test descriptions. Later the runner needs to execute all leafs of that tree as test cases.

A node in this tree of tests is not necessarily backed by a Java class, as it is for test suites. It can be something purely virtual. JUnit itself ships with a test runner for which this is true: org.junit.runners.Parameterized.

The screenshots above shows a Parameterized test on the left-hand-side and the Eclipse JUnit View (after the test has been executed) on the right-hand-side. The method parameters() returns a list of test data sets and the Parameterized runner will call the constructor of this test class for each data set. Consequently, the number of constructor parameters must match the number of items in each data set. For each data set, all test methods are executed and what we get, effectively, is a matrix test.

In the screenshot of the JUnit view we can see how the Parameterized runner presents the test matrix as a tree: The test class itself is the root node, every data set is a subtree and every entry of the test matrix is a leaf.

As of now (Eclipse Mars M4), it is possible to run individual subtrees by choosing "run" from the context menu. This effectively means to execute a row from the test matrix.

Additionally, it is now possible to run a single column from the test matrix by running a single method from a Parameterized test.

Note that in the picture on the left-hand-side I'm explicitly clicking on the method's name. Clicking elsewhere would execute all test methods from the class.

The new mechanism to filter down test description trees can achieve this without being specific to the JUnit's Parameterized runner: The filter first extracts the leading part of the test desription's name which is a valid Java identifier. The test is executed if this leading part exists and if it equals the to-be-executed method's name.

I would like to thank NumberFour for having me implement this fix specifically for Xpect. Gratitude also goes to itemis, my employer, who gave me the time to generalize and contribute the fix to Eclipse JDT. Also I would like to thank the JDT team for accepting the contribution.

63 comments:

Christopher Gerking said...

I'm afraid this works only with "primitive" parameter types, such as Integer in your example. For me it works with String, but not when using arbitrary classes as parameter types. Is that a known limitation?

Alan47 said...

@christopher: I've just downloaded the latest eclipse version to test this very behaviour. It works perfectly for me, even for rather complex custom classes.

Alan47 said...

One more remark:
- Run entire test class
- Select a test from the matrix and run it -> WORKS

But:
- Run entire test class
- Select a test from the matrix and run it
- Re-Run the previously selected test -> FAILS

Alan47 said...

My bad. My initialization procedure of the test data writes and reads some files, and if this is done more than once, it fails. This is why repeated test execution did not work. I missed the exception on the console.

Christopher Gerking said...

It works as long as the parameter class has a constant toString() implementation, which is precisely reproducible between two test executions. That's certainly not the case for the default toString() implementation.

On closer consideration of the solution description given by Moritz, this requirement is more or less obvious. Should be clearly documented nevertheless.

Christopher Gerking said...

To be more precise: it works as long as the name assigned by the @Parameters annotation is constant.

شركة التجمع said...

شركة رش مبيدات بالدمام

شركة تنظيف بالدمام

hasara said...

If anyone want to become an Dotnet certified professional reach Dot Net Training in Chennai
Software Testing Training in Bangalore

MNP Technologies said...

Very Good and Perfect Article.
To learn more about SQL, Software Testing and JAVA, please click on the following links.
Best Oracle SQL Training Institute in Bangalore
Best Software Testing Training Institute in Bangalore
Best Java Training Institute in Bangalore

Ayaz Alam said...

I really enjoyed reading the Post. It was very informative and useful for me.


Best Software Training institute in bangalore
Best SAP Training institute In Bangalore.
Best Advanced Excel Training Institute In Bangalore.

نورهان خالد said...


صيانة غسالات فيليبس
صيانة سيمنس
صيانة سخانات سيمنس
صيانة غسالات كريازي
صيانة سيمنس
صيانة غسالات هيتاشى
صيانة هيتاشى
مبيعات يونيون اير
تكييف يونيون اير
صيانة اوليمبيك
صيانة زانوسي
صيانة سامسونج
صيانة توشيبا
صيانة غسالات زانوسي
صيانة غسالات سامسونج
صيانة ثلاجات كريازي
صيانة ثلاجات توشيبا

Gokul Ravi said...

nice blog
android training in bangalore
ios training in bangalore
machine learning online training

Gokul Ravi said...

useful blog
python interview questions
cognos interview questions
perl interview questions
vlsi interview questions
web api interview questions
msbi interview questions

Gokul Ravi said...

laravel interview questions
aem interview questions
salesforce interview questions
oops abab interview questions
itil interview questions
informatica interview questions
extjs interview questions

Gokul Ravi said...

sap bi interview questions
hive interview questions
seo interview questions
as400 interview questions
wordpress interview questions
accounting interview questions
basic accounting and financial interview questions

ajay. chinna said...

Nice post keep do posting The Info was too good, for more information regarding the technology Click
Amazon Web Services Training
Devops training
Best Salesforce online Training

Anonymous said...

Selenium is one of the most popular automated testing tool used to automate various types of applications. Selenium is a package of several testing tools designed in a way for to support and encourage automation testing of functional aspects of web-based applications and a wide range of browsers and platforms and for the same reason, it is referred to as a Suite.

Selenium Interview Questions and Answers
Javascript Interview Questions
Human Resource (HR) Interview Questions

Ananya Krishnan said...

Good job in presenting the correct content with the clear explanation. The content looks real with valid information. Good Work

DevOps is currently a popular model currently organizations all over the world moving towards to it. Your post gave a clear idea about knowing the DevOps model and its importance.

Good to learn about DevOps at this time.


devops training in chennai | devops training in chennai with placement | devops training in chennai omr | devops training in velachery | devops training in chennai tambaram | devops institutes in chennai | devops certification in chennai | trending technologies list 2018

Dharani M said...

Nice blog...Thanks for sharing this information
best android training center in Marathahalli

best android development institute in Marathahalli

android training institutes in Marathahalli

ios training in Marathahalli

android training in Marathahalli

mobile app development training in Marathahalli

Harishnath said...

hi admin,
Thanks for your great and helpful presentation I like your good service. I always appreciate your post. That is very interesting I love reading and I am always searching for informative information like this. Well written article

pavithra dass said...

Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.
Java Training in Chennai
Java course in Chennai
Angularjs Training in Chennai
Selenium Training in Chennai
German Classes in Chennai
Java Training in Anna Nagar
Java Training in Velachery

franklinraj said...

Thank you for excellent article.

Please refer below if you are looking for best project center in coimbatore


soft skill training in coimbatore
final year projects in coimbatore
Spoken English Training in coimbatore
final year projects for CSE in coimbatore
final year projects for IT in coimbatore
final year projects for ECE in coimbatore
final year projects for EEE in coimbatore
final year projects for Mechanical in coimbatore
final year projects for Instrumentation in coimbatore

yashnit said...

Thanks For sharing Your Information The Information shared Is Very Valuable Please Keep Updating Us Python Online Course Hadoop Online Course Data Science Online Course Aws Online Course

meenati said...

very informative blog and useful article thank you for sharing with us, keep posting learn more Technology

Tableau online Training

Android Training

Data Science Course

Dot net Course

iOS development course

Rainbow Training Institute said...

Thank you for providing such an awesome article and it is a very useful blog for others to read.

Oracle Integration cloud service online training


Rainbow Training Institute said...

Thanks for providing a useful article containing valuable information. start learning the best online software courses.

Workday HCM Online Training

Unknown said...

What is web and digital design?
The aim of the Master’s course in net and Digital design is that the creation of various skilled profiles with in the web media design space that ar ready to set up, turn out and share through the online communities a replacement generation of content and services in an efficient manner. If you want courses oriented any details to contact us:
Digital Marketing Training Institute

shivani said...

An amazing web journal I visit this blog, it's unbelievably wonderful. Oddly, in this blog's content made without a doubt and reasonable. The substance of data is informative.
Oracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training

shivani said...

A befuddling web diary I visit this blog, it's incredibly grand. Strangely, in this present blog's substance made motivation behind fact and sensible. The substance of information is instructive
Oracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training

Mycoach Learning said...

Awesome post, Great to Land here, Keep going, have a great Success!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
we are providing Elearning Company in Chennai since
Digital Learning Solutions is a big boom to the Students and employee Engagement
Mycoach Learning is the best certified Elearning Company, which offers
Mycoach LMS

jenifer irene said...

Excellent post gained so much of information, Keep posting like this.
Aviation Academy in Chennai
Air hostess training in Chennai
Airport management courses in Chennai
Ground staff training in Chennai
Aviation Courses in Chennai
Air hostess training in Chennai
Airline Courses in Chennai
airport ground staff training courses in Chennai

shivani said...

An astounding web diary I visit this blog, it's inconceivably magnificent. Strangely, in this current blog's substance made point of fact and sensible. The substance of information is instructive.
Oracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training

VENU said...

Great blog created by you. I read your blog, its best and useful information.
AWS Online Training
Devops Online Training
Apllication Packaging Online Training

Aditi Ray said...

Thank you for sharing.
Check out the best furniture sale

IT Trainings said...

Just now I read your blog, it is very helpful nd looking very nice and useful information.
Digital Marketing Online Training
Servicenow Online Training
EDI Online Training

Nino Nurmadi said...

www.lampungservice.com
www.lampunginfo.com
lampungjasa.blogspot.com
beritalampungmedia.blogspot.com
lampungandroid.blogspot.com
lampung

DedicatedHosting4u said...


Just seen your Article, it amazed me and surpised me with god thoughts that eveyone will benefit from it. It is really a very informative post for all those budding entreprenuers planning to take advantage of post for business expansions. You always share such a wonderful articlewhich helps us to gain knowledge .Thanks for sharing such a wonderful article, It will be deinitely helpful and fruitful article.
Thanks
DedicatedHosting4u.com

Sravs123 said...

Just now I read your blog, it is very helpful nd looking very nice and useful information.
AWS Online training Institutes in Hyderabad
Devops Online training in Hyderabad
Data Science Online training in Hyderabad
Selenium Online Training in Hyderabad

shivani said...

An overwhelming web journal I visit this blog, it's unfathomably amazing. Unusually, in this present blog's substance made inspiration driving truth and reasonable. The substance of data is enlightening
Oracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training

Anonymous said...

Thanks for sharing such a great blog Keep posting..
AWS Training in Delhi
AWS Training institute in Delhi

wemake said...

Download latest audio and video file fromvidmate

shivani said...

An overwhelming web journal I visit this blog, it's unfathomably amazing. Unusually, in this present blog's substance made inspiration driving truth and reasonable. The substance of data is enlightening
Oracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training

tech updates said...

IOT TRAINING IN BANGALORE

lajwantidevi said...

vidmate app

Bala said...

Excellent experienced for me to read your great blog, I really impressed. I eagerly waiting for your future updates...
Pega Training in Chennai
Pega Course in Chennai
Excel Training in Chennai
Corporate Training in Chennai
Embedded System Course Chennai
Linux Training in Chennai
Spark Training in Chennai
Tableau Training in Chennai
Job Openings in Chennai
Tableau Training in Chennai

Tech Guy said...

For Data Science training in Bangalore, visit:
Data Science training in Bangalore

The India said...

Rice Bags Manufacturers
Pouch Manufacturers
wall putty bag manufacturers
fertilizer bag manufacturers
seed bag manufacturers
gusseted bag manufacturers
bopp laminated bags manufacturer
Lyrics with music

The India said...

we have provide the best ppc service.
ppc company in gurgaon
website designing company in Gurgaon
PPC company in Noida
seo company in gurgaon
PPC company in Mumbai
PPC company in Chandigarh
Digital Marketing Company

The India said...

we have provide the best fridge repair service.
fridge repair in faridabad
Videocon Fridge Repair in Faridabad
Whirlpool Fridge Repair in Faridabad
Hitachi Fridge Repair In Faridabad
Washing Machine Repair in Noida
godrej washing machine repair in noida
whirlpool Washing Machine Repair in Noida
IFB washing Machine Repair in Noida
LG Washing Machine Repair in Noida

The India said...

iso certification in noida
iso certification in delhi
ce certification in delhi
iso 14001 certification in delhi
iso 22000 certification in delhi
iso consultants in noida

The India said...

iso registration in delhi
iso 22000 certification cost
ISO 9001 Certification in Noida
website designing services
SEO Service Consultant

Mobile app development company in Mumbai said...

Mobile app development company in mumbai

Big Data Hadoop training institutes said...


Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
If you are looking for any Big data Hadoop Related information please visit our website Big Data Hadoop Training In Bangalore page!

raj khan said...

Soma pill is very effective as a painkiller that helps us to get effective relief from pain. This cannot cure pain. Yet when it is taken with proper rest, it can offer you effective relief from pain.
This painkiller can offer you relief from any kind of pain. But Soma 350 mg is best in treating acute pain. Acute pain is a type of short-term pain which is sharp in nature. Buy Soma 350 mg online to get relief from your acute pain.

https://globalonlinepills.com/product/soma-350-mg/


Buy Soma 350 mg
Soma Pill
Buy Soma 350 mg online



Buy Soma 350 mg online
Soma Pill
Buy Soma 350 mg

Online Training said...

Really nice post. Provided helpful information. I hope that you will post more updates like this

AWS Training

AWS Online Training

Huddlerise said...

Thanks for sharing the information....keep sharing more articles
Devops Training in Bangalore

Updated Tech News said...

For IOT Training in Bangalore Visit: IOT Training in Bangalore

IT said...

Security testing is must. Everybody wants security at every level of his working. as explained above failures are happened but if we test time to time then it will improve. So it depend on us how much we are serious about this.
Using Transposition Padding to Get CCA2 Security From Any Deterministic Encryption Schemes Project For CSE
MLP XSS An Integrated XSS Based Attack Detection Scheme in Web Applications Using Multilayer Perceptron Technique Project For CSE
Detecting Malicious Social Bots Based on Click stream Sequences Project For CSE
Emotion Classification and Crowd Source Sensing; A Lexicon Based Approach Project For CSE
Network Anomaly Intrusion Detection Using a Non parametric Bayesian Approach and Feature Selection Project For CSE
Spammer Detection and Fake User Identification on Social Networks Project For CSE

Tanika Co Valda said...

A IEEE project is an interrelated arrangement of exercises, having a positive beginning and end point and bringing about an interesting result in Engineering Colleges for a particular asset assignment working under a triple limitation - time, cost and execution. Final Year Project Domains for CSE In Engineering Colleges, final year IEEE Project Management requires the utilization of abilities and information to arrange, plan, plan, direct, control, screen, and assess a final year project for cse. The utilization of Project Management to accomplish authoritative objectives has expanded quickly and many engineering colleges have reacted with final year IEEE projects Project Centers in Chennai for CSE to help students in learning these remarkable abilities.



Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai


svrtechnologies said...

Thanks for Sharing such an informative stuff...

aws training

Jaswal Gupta said...

I blog quite often and I really thank you for your content. The article has truly peaked my interest. I will book mark your site and keep checking for new details about once a week. I subscribed to your Feed as well.
Find more

svrtechnologies said...

Thanks for Such an Informative Post...

aws training videos

Jack sparrow said...


I am a regular reader of your blog and I find it really informative. Hope more Articles From You.Best Tableau Training Videos available Here.