Programmatically run Eclipse IApplication

Does anyone know how to programmatically start Eclipse IApplication?

This is a command line application, and I want to write unit tests for it.

It should work like this:

org.eclipse.equinox.app.IApplication app = new myApp(); try { app.start(???); } catch (Exception e) { e.printStackTrace(); } 

The start method requires an IApplicationContext.

Where can i get this?

Many thanks for the help

+6
source share
2 answers

You launch such applications using the OSGi ApplicationDescriptor service. At Equinox, each of org.eclipse.core.runtime.applications turns into an instance of ApplicationDescriptor. Then you start the instance using the ApplicationDescriptor.launch(Map) method. Eclipse Help provides a very broad but concise description, and be sure to read about the power of the application on Eclipsepedia .

+2
source

This does not seem to be the right way to run the application programmatically for unit testing.

Instead, you can write Eclipse plug-in tests, and they can run the necessary OSGi container, where you can initialize your tests. Of course, you need to perform manual initialization associated with providing the appropriate set of tests, but in this case, you could manually call your code instead of relying on an external startup process.

Take a look at the following frequently asked entry http://wiki.eclipse.org/FAQ_What_is_a_PDE_JUnit_test%3F for details .

+1
source

Source: https://habr.com/ru/post/898078/


All Articles