Bug 316199 - [JUnit][API] Expose JUnitModel.exportTestRunSession(...) as API
Summary: [JUnit][API] Expose JUnitModel.exportTestRunSession(...) as API
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.7 M1   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2010-06-08 15:49 EDT by Mirko Raner CLA
Modified: 2010-06-23 06:44 EDT (History)
3 users (show)

See Also:


Attachments
Patch to expose API for importing/exporting JUnit test results (7.27 KB, patch)
2010-06-10 02:12 EDT, Mirko Raner CLA
markus.kell.r: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mirko Raner CLA 2010-06-08 15:49:04 EDT
There is currently no API that allows plug-ins to make use of the export methods in org.eclipse.jdt.internal.junit.model.JUnitModel:

 - exportTestRunSession(TestRunSession, File)
 - exportTestRunSession(TestRunSession, OutputStream)

Without a public API, plug-ins that wish to programatically save JUnit test reports or need to feed the XML data into some other process have to register their own TestRunListener and need to duplicate all the business logic that converts test results into the standard XML format. This affects all plug-ins that need to integrate with Eclipse's JUnit support or build additional functionality on top of it.

A possible solution for exposing the existing methods as API would be to add them as static methods to JUnitCore and simply delegate to the implementations in JUnitModel. The API methods would use ITestRunSession instead of TestRunSession in their signatures. This would be a fairly simple API addition that would be useful to many technologies that depend on or interact with JUnit.
Comment 1 Olivier Thomann CLA 2010-06-08 16:48:36 EDT
Move to JDT/UI
Comment 2 Mirko Raner CLA 2010-06-10 02:12:11 EDT
Created attachment 171604 [details]
Patch to expose API for importing/exporting JUnit test results

This is roughly what I had in mind. I also added the corresponding import methods to provide support for both directions of data exchange.
The only thing I'm not 100% happy with are the casts to TestRunListener in the export methods. However, given that ITestRunListener is not allowed to be implemented by client code and TestRunListener is the framework's only implementation class I assume that this will not pose any problems.
I understand that this contribution comes way too late for Helios, but hopefully it can be incorporated for Helios SR1 or Indigo.
Comment 3 Markus Keller CLA 2010-06-22 12:56:45 EDT
Thanks, that looks good to me.

Committed to HEAD with one change in JUnitCore#importTestRunSession(String, IProgressMonitor): If the import got cancelled, we now return null instead of throwing a CoreException.
Comment 4 Mirko Raner CLA 2010-06-22 20:55:11 EDT
Thanks for committing that :-)

Are these sort of non-breaking API enhancements usually also added to service releases of the current product version (i.e., Helios SR1)?
Comment 5 Markus Keller CLA 2010-06-23 06:44:57 EDT
> Are these sort of non-breaking API enhancements usually also added to service
> releases of the current product version (i.e., Helios SR1)?

Sorry, forgot to answer that. No, we don't add APIs in service releases (unless all hell breaks loose and the PMC allows an exception, but this bug is not severe enough for that).