It's all about the answers!

Ask a question

How can I convert a build result contribution to a JUnit Class Handle

S S (141418) | asked Mar 17 '15, 10:47 a.m.
Currently, JUnit tests are reported/displayed to the "Tests" tab of our RTC builds. I'm trying to write some custom tooling around getting the test suite/class names that fail out on each build. I've written code to get the build result contributions for each build. However, I'm having trouble converting those contributions into a form that I can use with the IJUnitTestCase and IJUnitTestClass api. Any suggestions/help with this would be really appreciated.

One answer

permanent link
sam detweiler (12.5k6194201) | answered Mar 17 '15, 11:05 a.m.
you need to retrieve the content from the contribution object. 

I don't know how to convert that to what you need.. I don't know what the data stream looks like.
here is a post with code to get the contents

S S commented Mar 17 '15, 3:36 p.m.

Thanks for the info, Sam. I've written a function to return a list of Build Results and I'm able to get the buildContributionResults for each build result. Here's an example: (stateId: <unset>, itemId: [UUID XXXXXXXXXXXXX], origin:, immutable: true)

Unfortunately, I don't see how I'm supposed to use this to get to the JUnit tests stored on the "Tests Tab".

sam detweiler commented Mar 17 '15, 4:43 p.m. | edited Mar 17 '15, 4:44 p.m.

I don't know 'exactly', but if you get the source for the plugin
then look at the code in

you will see how they create and view the unit test contributions,

to get the source, setup the sdk in eclipse, window->preferences, plugin development, target platform

then open the Plugin perspective, and find the plugin, then right click, import as source

then you can view the source in the eclipse project that matches the plugin name

S S commented Mar 23 '15, 2:10 p.m.

Sam, I was able to get the JUnit Handles for each build result: 
IJUnitTestSuiteContributionHandle junitHandle = (IJUnitTestSuiteContributionHandle) junitContributionHandles[j].getExtendedContribution(); 

I'm now having issues converting this to a IJunitTestCase so I can go in and grab the error data associated with each build result. I keep running into an incompatible type error.

sam detweiler commented Mar 23 '15, 2:42 p.m.

I haven't done anything with these types of objects..

as a debugging tool, you might print out the classname of the objects to see what type they are.

Your answer

Register or to post your answer.