does anyone know how to programmatically start an Eclipse IApplication?
It is an commandline Application and I want to write unit tests for it.
It should work so:
org.eclipse.equinox.app.IApplication app = new myApp();
try {
app.start(???);
} catch (Exception e) {
e.printStackTrace();
}
The start method requires an IApplicationContext.
Where do I get this?
Thanks a lot for help
You launch such applications using the OSGi ApplicationDescriptor service. In Equinox, each of the org.eclipse.core.runtime.applications
is turned into an ApplicationDescriptor instance. You then launch an instance using the ApplicationDescriptor.launch(Map)
method. The Eclipse Help provides a very broad if brief description, and be sure to read about the application cardinality on the Eclipsepedia.
It does not seem the right way to start the application programmatically for unit testing.
Instead, you could write Eclipse plug-in tests, and they can launch the required OSGi container, where you can initialize your tests. Of course, you have to do some manual initialization, that are related to providing the corresponding test suite - but in that case you could manually call your code instead of relying an external launch process.
Take a look at the following FAQ entry http://wiki.eclipse.org/FAQ_What_is_a_PDE_JUnit_test%3F for details
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With