Running a focused Groovy unit test from SpringSource Tool Suite (STS) - eclipse

I have a Groovy unit test class that has many unit tests. In the JUnit way I would normally run with the test function selected, but that doesn't work.
How do you run a focused unit test from STS? I know it's possible on the command line, but I'd like to do it from the IDE.

Run the entire suite once: Right-click on the file -> Run as -> JUnit test.
After all of the tests appear, you can terminate the process. Then select the unit test you want to run, right-click -> Run.
Alternatively, open your launch configuration dialog, create a JUnit test launch configuration. Select your project, package, and test class. You can also choose a unit test.

Related

Don't have option to create the jUnit test class

Junit test class option is not listed in eclipse and if I create a normal class and add the #Test annotation it still don't run the test class besides I have imported the junit jar files to my project but still eclipse is not running any test classes, can someone please help?
furthermore when I hit the other option still there is no option to choose Junit
For creating a suite: Choose Other and then choose Java -> Junit -> JUnit Test Suite.
Next page choose between JUnit 3 or 4 and click Finish
You can create Class with JUnit Test by choosing Other and then choose Java -> Junit -> JUnit Test Case.

How do I run NetBeans JUnit tests from the command line?

I am working on a Java application project in NetBeans. I have added JUnit tests, with the #Test annotation. The tests work fine when I run them from the ‘Run Tests’ menu item.
I want to run the same tests from a command-line script. I do not know how NetBeans does this. I want a single command for testing the whole project. How can I achieve this?
Netbeans uses Ant as a build tool, and its default Ant configuration contains a number of useful targets. You can list them with the command ant -projecthelp (executed in your project directory), which should output, amongst other things,
test Run unit tests.
test-single Run single unit test.
test-single-method Run single unit test.
So, simply executing ant test will run all your unit tests on the command line. This will run the tests, write the test results to the standard output, and finish up with a brief summary (including a BUILD SUCCESSFUL message if all the tests passed, or BUILD FAILED if not).
The ant test command will return an appropriate exit code (0 if all tests passed, 1 if any failed), which can be useful -- for example, if you want to add a pre-commit hook to your version control system to forbid commits with failing unit tests.
You should build your project on the command-line with a build tool like Maven, Ant or Gradle and not rely on Netbeans for building it. Please search for this tools.
You should also consider to read a book about software development like Head First Software Development. They explain why and how to us a build tool (e.g. chapter 6 1/2 of Head First Software Development).

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

ScalaTest runnning only a single test in a suite

While developing a test suite for a class, I've began running into situations where ScalaTest would only run a single test, or exclude some of them.
Eclipse was saving different runs of the tests as different run configurations, and depending on how I ran it (usually using Ctrl+F11), it selected specific tests in the suite, not the whole suite class, and saved those run configurations.
The solution was to delete the new run configurations, and simply right-click the name of the test suite class in the editor, and select Run as -> ScalaTest - Suite. More information
Additionally, you can tweak how Eclipse interprets the run command/shortcut, when you go to Preferences -> Launching:
I have selected Always launch the previously launched application, and now Eclipse isn't trying to dynamically create run configurations anymore. When I switch between the main application or test suits, I have to do it manually using the dropdown near the green Run buton.