How to use JUnit to test IOperationParticipant?
Hi,
I'm trying to optimize the tests on my customizations. I read several materials about it: (https://jazz.net/wiki/bin/view/Main/JazzTalkWalkthrough, http://jazz.net/wiki/bin/view/Main/JazzBotWalkthrough, http://jazz.net/forums/viewtopic.php?t=7009&highlight=junit). But I have to admit, I'm still struggling to understand it. I'd use JUnit before on regular projects and I have a little experience developing bundles for RTC, but I had a cloud of doubt above me. For example, I'm not quite sure how can I select a project area and create an workitem to test a follow-up action and get the message that would be displayed to the user. I guess I have to use Plain Java Libraries right? I start with something like this:
Where I go from here? or more important what I've done is correct so far? Another doubt, I have to make this as a plugin to extend AbstractRemoteServiceTestCase or a standalone JUnit do the job? |
One answer
Here are some advises:
1. You will need to use AbstractRemoteServiceTestCase. 2. In the class that implements IOperationParticipant, you can use IParticipantInfoCollector.createInfo() and IParticipantInfoCollector addInfo() to create any message. 3. You should have a default project area created for testing. You can do this in setup method. 4. You should have already had the operation object. 5. In the test method, you should use IServerProcess to execute the operation and use the report to do the validation. IServerProcess serverProcess = getService(IProcessInternalServerService. class).getServerProcess(aProjectArea); IOperationReport report = serverProcess.adviseAndExecute(operation); IParticipantReport[] participantReports = report.getParticipantReports(); IParticipantReport myReport = null; for (int i = 0; i < participantReports.length; i++) { IParticipantReport participantReport = participantReports; if (participantReport.getParticipantIdentifier().equals(TheParticipant. ID_PARTICIPANT)) { myReport = participantReport; break; } } assertNotNull(myReport); IReportInfo[] infos = testReport.getInfos(); //check the infos |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.