Eclipse execute Maven build with tests - eclipse

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

Related

KIE Workbench Test Scenarios as a part of Maven build

In my current project we need to run Test Scenarios created in Workbench as a part of a Maven build. The final goal is to have these functional tests included to the continuous integration process.
We spent a couple of days trying to figure it out.
We opened a project that is created by Workbench in the .niogitfolder and are trying to run a maven goal.
But seems that maven goals like mvn clean install or mvn clean verify or mvn clean test don't run the Test Scenarios having a .scenario type at all.
Do you have any ideas on that?
Test scenarios are specific to kie-workbench. maven commands will not execute them during build. If you want tests to be executed during maven build then you have to write junit tests to check the execution of rules and processes.
there is currently work in progress on new version of scenarios in the kie-workbench. See the list of tasks. I would recommend you to bring this requirement there.

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.

Build NetBeans Ant Project from Gradle

I'm converting our build from Ant to Gradle. Our first step is to add the Gradle build files so we can start using Gradle as our build tool. This lets us use our existing build scripts to build using Ant and convert them to Gradle over time. I want to simply have Gradle call the existing Ant build files. Our projects are all NetBeans projects, which have build.xml and nbproject/build-impl.xml files. Some of the projects require NetBeans build properties, which can be found at ~/.netbeans/6.5.1/build.properties. I have the NetBeans user.properties.file property successfully set to ~/.netbeans/6.5.1/build.properties.
When I build with Ant, I invoke this:
ant -Duser.properties.file=~/.netbeans/6.5.1/build.properties dist
This executes the dist target, which depends on the init target which depends on the targets listed below:
pre-init, init-private, init-userdir, init-user, init-project, do-init, post-init, init-check, -init-taskdefs
The targets listed above are executed in the order specified. When I invoke 'gradle dist', it invokes the init Ant target, but then it executes the targets listed above in reverse order, starting with -init-taskdefs. There are required properties which are setup in the targets before the -init-taskdefs target which aren't being setup when run from gradle.
Really, all I want to do right now is to use gradle to invoke Ant to build my projects. What's the best way to do this since using gradle to build using Ant build.xml files doesn't seem to work as expected? Do I have to resort to using exec? (I hope not).
I found trying to use Gradle's integration of Ant with a Netbeans project was too difficult and error prone. Instead, I use Gradle's exec() command. Below is an example, lifted from my code that builds a NetBeans Project named 'Common Library'.
task commonLibrary {
doLast {
ant.echo("Building Common Library")
exec () {
workingDir = "../netbeans/nb/CommonLibrary"
executable = "ant"
args = ['clean', 'jar']
}
}
}
I realize that wasn't the answer you were hoping for, but posted it as a possible solution for other people, particular people who aren't in a position to start reworking their build.xml files.

m2eclipse filtering test resources

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