Writing unit tests for JUnit launches [message #1277862] |
Wed, 26 March 2014 11:08  |
Eclipse User |
|
|
|
I'm trying to write an end-to-end test fixture using the Eclipse PDE JUnit runner to verify that a sample launch is running successfully. The following should fail:
public void testTestRunner() throws Exception {
// given
ILaunchConfiguration configuration = launchManager.getLaunchConfiguration(project.getFile("test.launch"));
// when
ILaunch launch = configuration.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
// then
while(!launch.isTerminated()) {
sleep(500);
}
for(IProcess process : launch.getProcesses()) {
assertEquals("runner process " + process + " failed", 0, process.getExitValue());
}
}
I deliberately wrote a test fixture in the example project so it would fail. But this passes!
How are other people writing JUnit PDE tests for their customised launches? Without mocking?
|
|
|
|
|
Re: Writing unit tests for JUnit launches [message #1279009 is a reply to message #1278451] |
Fri, 28 March 2014 01:42  |
Eclipse User |
|
|
|
Ricardo,
I really have no clue, so maybe someone else with a clue will comment.
However, if I were trying to figure this out myself and no one helped
me, I would try to figure out how the JUnit view knows what to display.
Alt-Shift-F1 (plug-in spy) will give you information about what's
implementing the things you see in the IDE. Using that, I would start
looking at how org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart
works its magic.
On 27/03/2014 12:02 PM, Ricardo Gladwell wrote:
> Hi Ed,
>
> The array returned by launch.getProcesses() is definitely non-empty.
> If I put an assert like this:
>
> assertTrue(launch.getProcesses().length > 0)
>
> It would pass.
>
> Any ideas, thoughts or suggestions would be great :)
|
|
|
Powered by
FUDForum. Page generated in 0.07762 seconds