m2eclipse filtering test resources - eclipse

I am using m2eclipse and I want to right click and run tests from inside eclipse while the test resources get filtered from Maven. How can I do this? From eclipse when I right click on a test I do not get any m2eclipse options
Julia.
Similar to:
Debugging maven junit tests with filtered resources?

Setup filtering in your pom.xml (and you'll get filtering under Eclipse with m2eclipse, m2eclipse runs process-resources after a change of any resource).
Run your test as any other test (right-click then Run As > JUnit Test).
After a first run, you can run an individual test method (right-click on the method in the JUnit view).

Right click on the project -> Run As -> Maven test

Related

Spock script not compiling automatically in Spring MVC project which is using Eclipse IDE

I am working on a Spring based web project (Eclipse as IDE), in which we want to introduce integration testing framework using Spock. This project is based on Maven. For this purpose I have installed Greclipse plugin and converted the existing project to groovy nature. Also configured Maven to run the test classes in src/test/groovy folder, and everything working fine and all the spock tests are running fine with run "Maven test" phase. Configured the build path to compile the groovy test files to target/test-classes.
The problem is coming when I run the Spock tests using Run -> Run configuration. It runs file with Junit runner using run configuration, it is picking up the compiled test class from target/test-classes. Whenever I modify the Spock test script file, it is not automatically generating the classes, Run with Run Configuration is always picking up the old compiled class.
How to force the script to compile so that I don't always need to Maven clean and Maven test, to force it compile and run.
I have found in some other threads talking about modifying the Groovy compiler options to "Enable script folder Support", both checking and unchecking is of no use either. Its not forcing the Spock script to compile (also tried enabling the same option in Eclipse Preferences global Groovy compiler option)
Any help is greatly appreciated.
Spock tests are implemented as a class extending Specification. So they are treated like any other Groovy class.
If in Eclipse under "Project" → "Build Automatically" is enabled, Eclipse compiles the classes automatically on every change. So if you change a Spock test in Eclipse, running it should always use the newest compiled version.
For automatic compilation to work correctly, the source has to be configured properly in Eclipse. Check via "Configure Build Path..." on your Eclipse project that under the "Source" tab the src/test/groovy/ folder is configured correctly.

Run multiple RCP junit tests encompassed in multiple bundles

We have multiple RCP bundles and seperate fragment projects to test these bundles with either RCP plugin or plain jUnit tests.
Problem
To test the well functioning of the whole ecosystem we would like to run all tests from all plugins before we push new code to our CI environment.
Yet, till now we only figured out how to run the tests inside single projects at once. Thus, to run all tests on all plugins we currently select one plugin at a time and execute the tests inside via the context menu. This manual process is error-prone.
Question
Is there a way in the eclipse IDE to run all tests inside all plugin projects at once?
The easiest way is to create a Launch Group; you can find it under Debug Configurations.
Add all your existing JUnit (or JUnit Plug-in Test) launch configurations to it and then hit the Debug button.
Unfortunately if you create additional JUnit Plug-in tests after this Launch Group was created, then you have to add those new Plug-ins manually.

Eclipse execute Maven build with tests

In simple words: How to runs in eclipse tests with building process (as simple as possible)?
I want to execute test defined in pom with every maven build. Currently all is build, but none test is run. When I execute maven test it runs test, but during build it only builds.
How can I add this phase to eclipse build process?
I already read Eclipse Maven Build and Test with One Button, and it is close to optimal, still I would like to run tests with build to be more TDD.
My solution(might not be optimal):
require maven runpath
Go to Project -> Builders
Add new Program
In Edit configuration enter (as on picture):
Location: your/maven/path
arguments: test -f /yourProjectPomPath/pom.xml
As on picture tab Build Options -> Check(click) During auto builds option select
Save changes and check if all works

Aggregate surefire reports of maven project hierarchy as XML for eclipse?

I have a project hierarchy which built with maven. How can I run all the tests in the whole hierarchy at once from eclipse and easily go to the failures?
The maven surefire plugin spews loads of output at the console, but it is tiresome to find the failures there. It also generates XML report files which I can easily open within the normal eclipse JUnit view - but these are many many files and it is difficult to find the files of the failed tests. The maven surefire report plugin allows to aggregate all test results with mvn surefire-report:report-only -Daggregate=true but only in HTML format. What I'd love to have is an aggregation of all test results in the eclipse JUnit view - just as I get if I use "Run as JUnit-Test".
(Ideally, I would start all the unittests with "Run as JUnit-Test", but I can do that only for one project, not for all the projects in the workspace.)

GWT - Refreshing changes with 'Development Mode' with Maven

If I use GWT's Development Mode with Eclipse, changes that I make in the IDE are immediately reflected in my browser upon refresh. However, I can't seem to get the same result when using the maven plugin to build. Is this possible?
Here's what I've tried:
Running gwt:run, making a change and saving it in Eclipse, refreshing the browser.
Same as above but clicked the 'restart server' button on the GWT Development Mode console.
Telling Eclipse that my project is a GWT project and configuring a Web Application, but it fails to list any Entry Point Modules for me to choose from.
'webAppCreator -templates maven com.xx.WebApp' - creates just a pom, no project (?).
The only option seems to be: stop the console, gwt:compile, gwt:run. This cycle takes minutes each time..
Any ideas on how to achieve this, or if it's even possible? Not being able to do this is really a show stopper for us adopting GWT, since we can't scrap maven.
TIA, Roy
The real answer to this question came from Thomas Broyer's comment, but I wanted to spell out all of the steps that I took for future reference:
With Maven:
Create the project using the gwt maven plugin archetype.
Move the xxx.gwt.xml file from the 'resources' tree to the 'java' tree, as recommended by Thomas.
Run 'mvn clean install' to ensure that all's well, and to generate the async classes.
To get around this issue, add this to your pom. When you change your maven dependencies you'll need to run a maven compile to get them to take in Eclipse.
With Eclipse:
Import the project into Eclipse using 'Import Existing Maven Project'
Right-click on target -> generated-sources -> gwt, and select Build Path -> Add to Build Path.
In project properties -> Google -> Web Toolkit, 'Use Google Web Toolkit' is checked.
On the same page, add your entry point modules.
In project properties -> Google -> Web Application, ensure that 'This project has a WAR directory' is checked, and the dir points to 'src/main/webapp'
Right-click on the project, select Run As -> Web Application
Ready to go!