How to test an application as JUnit-Plugin test in Eclipse - eclipse

I am trying to set up a JUnit Plugin test for a RCP-Application. Thereby I am using Tycho (0.18), maven 3.0.2, eclipse INDIGO and JUnit4.
When I configure a Plugin Test, the to be tested application starts as expected, but the chosen test case does not run. Whereby I do not get any error or exception messages.
Because I did not find anything with google, I would be very happy if someone could provide some helpful information or tutorials.
Update: I have found this tutorial: How to JUnitPluginTests. But the UnitTests didn't start without any error message...
I have the assumption that the JUnit-Plugin-Test launcher does not work in a correct manner. Because I have to define my application separately in the arguments tab, else the following error appears:
Application "org.eclipse.pde.junit.runtime.nonuithreadtestapplication" could not be found in the registry

Have you checked Christian Pontesegger's tutorial on Tycho, which includes a post about tests?

I had apparently the same problem. I tried a number of things, but what worked for me was:
Open the run configuration
Switch to the Main tab
Select 'Run an application'
Select '[No Application] - Headless mode'
I didn't need to run my product and this allowed the JUnit plug-in test runner to locate the unit tests.

Related

Gwt Production Mode in IntelliJ IDEA

Specifically, I wonder how to compile project for production mode in IntelliJ IDEA. So far I have found only dev mode mentions and the official JetBrains guide describes only devmode. Now, when I compile my gwt module in IDEA using "Compile module" from context menu and try to run it in browser calling:
localhost:8888/MySampleApplication.html
I always get message "Gwt module need(s) to be recompiled".
I have defined a maven run configuration with the command line:
clean gwt:compile -Dgwt.inplace=true
Now the compiler writes his output in the source directory ( in our case /src/main/webapp). If I take now the url without the parameter for the codeserver I get the correct results.
I hope this will help!

Eclipse plugin development: Missing dependencies at runtime

Background
I'm currently trying to extend Junit (org.eclipse.jdt) in order to do some tracing.
Therefore I created my own plugin project which (among others) provides a class which should be used by the junit runtime plugin.
I have setup my project as a dependency for junit and the package containing my class is listed as "exported" in my Manifest in the runtime tab. If I run the plugins as an eclipse application everything builds and starts allright and.
Problem
However, if in the started eclipse I perform a "Run as Junit", I get a NoClassDefFoundError concerning my class. In my understanding this means, that at runtime my class is not visible in the started eclipse. I thus printed the classpath while running and like expected my plugin doesn't show up.
Do I have to add my plugin to the "runtime" settings of the junit plugin? In the Manifest, my package is not available under the "export -> add" button. I tried importing a jar of my plugin and configuring those exports manually here, but this did not help either.
My thought process kind of gets stuck with this "run in run" configuration...
Any help is welcome!
Digging deeper in the code I found that the reason for the error is, that the part which calls my code and throws the error is run in a seperately started VM which has its classpath set via code. Nothing was wrong with the configuration, it just was not used in this case.
So if you ever stumble upon a "VMRunnerConfiguration" while having classpath problems, this might be your problem. ;)

Error in MANIFEST.MF of SWTBot test plugin

I would want to try out SWTBot to test our RCP application's user interface. For that I started with the sample test which worked perfectly as documented here. I wanted to try similarly on our application and for that I checked out our UI plugin and was able to launch it as eclipse application. Then I created a new SWTBot test plugin. Just after creating test plugin, I see error "Bundle 'org.eclipse.swtbot.go' cannot be resolved" in MANIFEST.MF file on line "Require-Bundle: org.eclipse.swtbot.go".
I am not sure why I am getting this error only when I try to create the test plugin for our custom RCP application and not when I am trying out the example provided in the above link. I compared both test plugin MANIFEST.MF file but left with no clue.
Has anyone faced such error while creating the SWTBot test plugin for the custom RCP application?
Thanks in advance !!
Prakash
Make sure the org.eclipse.swtbot.go is actually the name of the plugin (maybe the plugin is called something else).
Make sure your target platform in PDE contains the SWTBot stuff. You can also use the PDE Plugins view to see if you see the SWTBot plugins.

PlayN GWT/HTML, keeps insisting module must be (re)compiled

I created a new PlayN project from the 1.2 archetype using the command line given in the GettingStarted wiki page. I then imported this Maven Project into Eclipse, just bringing in the core, java, and html modules. If I right-click the Java project, I can choose my main class, and a window pops up with the background image shown. Note that I've done no real programming yet: I'm just using the default project configuration.
Next, I used GWT-compile through Eclipse on the HTML project, and I got no errors. When I run it as a Web application by using the provided URL (without removing the "?gwt.codesvr=127.0.0.1:9997" bit), the application runs fine aside the Eclipse Console gives a warning about being in Development Mode. (Specifically, "You are running in GWT Development Mode. For optimal performance you may want to use an alternative method.")
However, if I run the application the recommended way, by removing the gwt.codesvr parameter, then I keep getting a dialog box saying "GWT module 'testproject' may need to be (re)compiled."
After reading How do I run a maven/eclipse/GWT/playN app in production mode?, I tried doing mvn test -Ptest-html
and then pointing my browser at http://localhost:8080, but it gives the same error.
Am I doing something wrong?
(EDIT: I have no idea if this next point is significant or not, but I'll share it anyway. When I try to create a project from Eclipse, the newest PlayN archetype I can see is 1.0.3, even after telling Eclipse to update the Maven index. I'm running Eclipse Indigo.)
I guess you are running PlayN 1.0.3.
There is a bug in 1.0.3:
So you need to do the following:
Run GWT-Compile
Run the web application and get the error message: "GWT module 'testproject' may need to be (re)compiled."
Run again GWT-compile, while the Web-Application is running
Reload your browser with CTRL-F5
The important step is step 3.
Note:
You can update to PlayN 1.2 to get rid of the error. For this you have to change the file playn-showcase/pom.xml.
Change the line
<version>1.0.3</version>
to
<version>1.2</version>

How to run Eclipse launch configurations programmatically?

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.
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
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.
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.
You could also use the shell command Eclipse uses. To get it:
Run your program in Eclipse
Go to the "Debug" view
Right-click on the process (probably the second item in the tree) and select "Properties"
Copy shell command and delete the agentlib flag to run in bash
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.
Perhaps running the configurations the way you would run your own custom run configurations would help here. It is described in this article.