Automate Runs in Eclipse - java

I have a main class that takes a series of arguments and I have 10 run configurations. Is there a way to have eclipse run them one after another?

The other answers are probably better solutions to your problem. However, if you install the Eclipse CDT into your Eclipse installation (using update manager or market place client), then you get an additional launch configuration type called Launch group.
Those launch groups allow creating a list of other launch configurations to be run one after the other. Make sure to set the Post build action in the dialog to "Wait until terminates" for each included launch configuration.

#Steven: To do it quick, you can write a JUnit Test case that just calls the intended classes in desired order and execute it. Eclipse already has the necessary jar for JUnit, so you are ready to go. Definitely, writing ANT/MAVEN script is a good practice.

As #gotuskar suggested, write test cases for your class. If you can afford running your ten configurations each time you build your project put them in its src/test/java directory, otherwise create a sibling project to your original one, make it depend on it, and put your tests there.

Related

A GUI for running set maven commands with parameters?

Full transparency, I really don't know my way around maven. I have created an automated test suite using cucumber, and I run all my tests through maven commands e.g. simplest one is below
mvn clean verify -Dcucumber.options="--tags '#TestTag'"
The above, will run all cucumber tests with the tag #TestTag. Parallel runs and everything else is running fine. However, I would love a user interface of sorts where I can pass the tag parameters amongst other items that I have added to the pom as properties (e.g. -Dnumber.of.devices=2, -Dtype.of.run=fragmented).
Something like a dropdown that lists all my available tags, a swith to mark it as distributed/fragmented, a dropdown to set the number of devices to run against. At the moment, I'm manually creating each maven command for each run, saving them when neccesary to Intellij configurations. But is there any tool out there that I can just add the parameters I care about, and it will run the command with those parameters added to my mvn clean verify command?
Something like
mvn clean verify -Dnumber.of.devices=<NUMBER_ENTRY> -Dtype.of.run=<FRAGMENTED_OR_DISTRIBUTED> -Dcucumber.options="--tags '<CUCUMBER_TAGS>'"
I have already taken care of how those properties will determine the type of run I want.
I would have thought there would be something like this that exists, but can't find anything. I'm totally aware that what I'm asking is ridiculous/silly. Anyway, if anyone can point me towards something or offer advice why this isn't a thing, I'd be very much appreciative.
Thanks
Jenkins. It was Jenkins. I avoided it because reading about it seemed kind of daunting. But once I set it up, it was pretty easy. I now have all my configs as I want them, looking forward to digging into the million plugins they have available.

Continuous testing with IntelliJ Idea

I'm looking for an IntelliJ IDEA plugin that would run my tests each time I change my code. I looked for such a solution and I found:
Infinitest, which works, but is inconvenient because I need to add the facet to each module, and it opens a new tool window for each module (which means 15 tool windows for me).
Fireworks - didn't work for me, maybe it just doesn't work with IDEA 14 (in its repo I can see that last changes were made in 2009). IntelliJ also reports that it throws exceptions.
There are lots of ways I could run all my tests (including writing a simple script for this), but I'm looking for a tool that would be smart enough to rerun failed tests first, and that would understand module dependencies (so after a change in some module it would run only tests of dependent modules).
I prefer free options, but if there's something paid for a reasonable price, I would accept it as well.
IntelliJ now actually has a Toggle auto-testin the run dialog. Just run a run-configuration and then select Toggle auto-testin the run dialog.
It's not as intelligent as you would have hoped. It just reruns when it detects changes.
I know this is a 3-year-old question but I think it will help people who face the similar problem in future. So I found out a way to enable SBT style auto test execution in IntelliJ studio.
We need to do 2 things to enable auto test execution.
Enabling auto project build - This can be done in settings by going into File -> Settings -> Build, Execution... -> Compiler and selecting "Build Project automatically".
Enabling "Toggle auto-test" in run dialog box
This will start auto testing. Although this works fine, it takes time to build the project even when my project is tiny so for larger projects it will certainly take very long time to complete the build and execute tests.
Reference: Original article which explains these steps
If you are OK running tests which cover a single method chosen by you, you can try this plugin (it is continuos in the sense that you make changes to a method, then click on the method and the plugin will run all the unit tests automatically which cover that method): https://plugins.jetbrains.com/plugin/15063-unit-test-coverage-history-runner
You can use the Intellij Teamcity plugin. Teamcity is a paid product but there is a free version which gives you 20 projects and 3 agents for free .
It has a remote run feature using which you can send in unchecked code to run tests before committing.
It also has options to run failed tests first
Usage instructions for Remote Run

Adding Spock tests to Java project in Intellij

I have an existing Java project set up in Intellij 12 and am attempting to add some Groovy classes to it. I've started with attempting to add a simple Spock class for testing purposes, but when I right-click on the class it does not give me an option to run it.
I've taken a look at my Intellij configuration and it pulls in groovy correctly. Further, I can write a Groovy script that uses a Groovy class and that runs without problems so it appears that Groovy is wired in. Is there something else I need to configure to specifically run Spock tests?
Easiest way to get spock and all dependencies is add library from maven.
Then, you should place your test in a folder, marked as test folder, if you want to allow batch processing of them.
If you place your script in folder, not marked as test, or source folder, you will be unable to run it.
If you can't see run button, it looks like Idea cannot recognise file as runnable, it isn't under source/test root, or it's extension is invalid.
You can add Spock plugin by:
Downloading the jar
In IDEA File->Settings->Plugins->Install from disk. Choose the jar.
I was having the same issue and ended up here. I found that I had forgotten to extend spock.lang.Specification. As soon as I did, the Run option showed up.
Just posting in case it helps any other Spock novices like myself.

Is it possible to run Eclipse application and Junit plug-in test simultaneously?

I have an eclipse application, where in i can create projects and perform some operations. I have written a test cases using Junit for some functions. To run these test functions, i am doing Right click on test class and Run as Junit Plug-in test and it is working properly. I am unable to do both the things at the same time. What i need is to run my eclipse application and Junit plug-in test simultaneously without human intervention. Junit plug-in test has to be done at run time. If there is a way to do that, then please suggest me the solution.
When you run it as Junit plugin test, then it already launches your eclipse plugins (and application), so there is absolutely no need to try to launch an additional application.
What probably confuses you, is that the test run and the "normal" manual run use two different workspaces. So if you try to access some files in your test which you created during normal operation, they will not exist. But you should never rely on such things, instead you have to create the necessary artifacts in the test setup method.

Netbeans - run specific Maven integration test

How can I configure Netbeans to call Maven Failsafe to run a specific integration test?
I know the Maven command to do this is 'mvn -Dit.test=MyClassIT verify' I also know how to configure 'actions' in Netbeans Project properties.
My problems are:
Netbeans sometimes runs the action (and calls Maven), and sometimes just uses its own compiler and test runner. Don't know how to tell it to use which. Bizarre
Netbeans adds "Test" to the class name. Instead it should add "IT". But the bizarre part is that there's nothing in the action that defines this behavior. The action just passes the class name.
I don't want to override the normal Test File and Debug Test File actions, because I need those for normal tests. But custom actions only appear in the Project's 'Custom' context menu, and not for any individual file! So they're unusuable. It would also be nice if I could make toolbar buttons for them.
If the planets align correctly and Netbeans issues the right command, Maven is launched with correct settings, but the debugger doesn't work
Using Netbeans 7.1 and Netbeans Dev 201201260600
If you right click on a project, theres a 'custom' option with as only one child option 'goals'. You can use it to run custom mvn commands; also notice that old commands are kept, so you don't need to type it every time.

Categories

Resources