How to run Eclipse launch configurations programmatically?
Asked Answered
D

6

41

I'm finding it difficult to phrase this question well, as there are quite a few generic terms (run, configuration, launch, etc.). Here goes:

You can save run configurations in a .launch file. (in the Run Configuration Dialog, under the Common tab, Save as a shared file.

We check these in to SVN. The developers can pass them around, and it helps getting new devs running a working application quicker.

I'd like to check these out as part of our build and use them to programatically run the application, the tests, etc, without spinning up the whole IDE.

What would be the best way to run a .launch file outside of the UI?

Edit: I am trying to unify the tests run on the build server and the IDE. I do not particularly want to give up integrated debugging, which would be the case with an ant script to run the tests .

This is probably more a problem for integration testing with multiple bundles, or unit testing a whole bundle, where you'd like to mock up extensions.

Delia answered 21/10, 2008 at 14:31 Comment(9)
+1! I'm new to Eclipse and had such a hard time saving a launch configuration into the source so I could commit it to SVN! I found your question which answered my question before I asked it. Thanks!Suboceanic
For anyone here looking at a way to just run what you have built in eclipse you can use the 'Export' context menu on the project (in Package Explorer) to create a 'Runnable JAR file'Equate
However, this does not consider running unit tests, running RCPs, applets or OSGi configurations.Delia
Running RCP without eclipse environment? are you able to mimic eclipse environment to test the plugin without an eclipse exe running????Wheelhorse
@Wheelhorse The non-UI bundles, yes. However, this isn't just limited to RCP/OSGi development - any .launch file can contain any sort of tests. I'd like to be able to run these in the same way you may run a TestSuite.Delia
Is it not possible to run the same launch file from eclipse in your build machine? This would be more exact tests casesWheelhorse
I think that's what the question is about. :(Delia
Did you ever find a solution? I'm trying to do something similar as wellAirfoil
Also looking for a solution similar to this.Spicer
S
4

there is an eclipse plugin built over JUnit, called TPTP. It provides an automation client which can be used to launch the test from eclipse with no gui. maybe it helps

Senegal answered 20/3, 2009 at 14:43 Comment(0)
D
2

Ant4Eclipse may provide a good starting point on how to do this.

Unfortunately, this is limited to Java Applications and JUnit configurations; I am more interested in PDE applications and Plugin JUnit tests.

Delia answered 21/10, 2008 at 14:31 Comment(0)
A
2

I have recently had alot of success building an Eclipse RCP app inside a Hudson CI server using Eclipse Buckminster. It took a bit of doing, but once I setup both features, made my RCP product be based on features, and added the Buckminster query files and the like, it worked. There is a Hudson/Jenkins Buckminster plugin that allowed me to have hudson build the application.

After saving the launch configurations for each test fragment, I created hudson commands to invoke them (yes one line per test fragment unfortunately), but after that I got the automated CI build that I wanted.

Adowa answered 12/4, 2012 at 17:36 Comment(0)
A
2

You could also use the shell command Eclipse uses. To get it:

  1. Run your program in Eclipse
  2. Go to the "Debug" view
  3. Right-click on the process (probably the second item in the tree) and select "Properties"
  4. Copy shell command and delete the agentlib flag to run in bash
Accredit answered 26/6, 2013 at 22:52 Comment(0)
P
1

I think you don't need to use the .launch configurations to run the tests. If you build an application using the Eclipse Build System, then you can use the AntRunner application from Eclipse to run your units tests. This doesn't start the whole IDE.

This article describes how to run the tests during your build process. With this process, you use a special "Test" Eclipse and load the plugins you want to test.

Parma answered 20/3, 2009 at 15:37 Comment(1)
The problem I'm trying to avoid is that of keeping the build/test/deploy metadata all in synch. If I can get everything running from the same set of metadata...Delia
C
1

Perhaps running the configurations the way you would run your own custom run configurations would help here. It is described in this article.

Corrasion answered 17/6, 2009 at 23:28 Comment(1)
This article allows us to define our own launch configuration types. We want to be able run existing configurations. Unfortunately, these launch configuration types (plus the framework itself) are all in org.eclipse.jdt.debug.ui, so not really suitable for a headless build server.Delia

© 2022 - 2024 — McMap. All rights reserved.