I have a series of automated java tests as part of a maven project in java. I have just switched machines from a machine where the tests run fine.
Now, when I right click on the test java class, there is no 'Run', 'Debug' options. Only the main option at the top of the window - which doesn't work either.
I have checked the Junit plug in is installed and I have Invalidated Caches and restarted.
Any ideas?
Thanks
You need to "edit configuration" and add run configuration for your test class.
Here is the example for JUnit but for TestNG it should look similar. You expand the combobox on the top right and choose "Edit Configuration..". Then you add JUnit/TestNG configuration and in configuration details specify the test class to run.
Related
I have a library I'm creating using Intellij. I am doing TDD with ScalaTest and SBT to run my testing library. I want to set a breakpoint in Intellij for when it runs my tests to stop at a particular line so I can do inspection. How do I setup the run configuration to do this? When I extend my library class to extend App to give it a main method it doesn't even allow me to add it as the 'Application' run configuration in Intellij. I don't actually want to have that as a run configuration, I just want to be able to set breakpoints.
IntelliJ has a module to test scalaTest classes. Just right-click on the name of your class, and click on Debug in ScalaTest (the first time around, you should have a dropdown on Debug to select how you want to run it).
I have multiple spring boot applications in a single IntelliJ project. And i want to have a single button to run all of them in some order.
I know there is an option to Run Another configuration before launching the original one, so in that way the configurations can be chained.
But when i use it, it runs that Another Configuration and doesn't run the original one.
So I'm wondering if anyone met this issue and how it was resolved?
You could create a Compound run type and add all your applications in it. That way you can just run that config and all your apps will start.
Update April 2016:
Multirun Plugin says:
Prefer to use built-in support starting from IntelliJIdea 15 https://www.jetbrains.com/idea/help/run-debug-configuration-compound.html
Stéphane's answer works great but if you need additional features you can install the MultiRun Plugin that will allow you to do the same as the Compound run type but with more bells and whistles.
https://plugins.jetbrains.com/plugin/7248
For instance:
You can set a delay between each configuration run or run one configuration after another using the Before Launch feature.
See here for more info about how to setup: https://github.com/rkhmelyuk/multirun/wiki/How-to-run-configurations-with-Multirun
Update April 2018:
On the "Run configurations" combo box, click "Edit Configurations". Then uncheck "Single instance only" option. Then click "Apply".
Then you can click the button "Run" any times you want, launching a new instance each time.
IntelliJIDEA Ultimate 2018.1
Env:
IntelliJ IDEA 2021.1.3 (Ultimate Edition)
Steps:
Go to Run configurations combo box.
Click Edit Configurations....
Check Allow parallel run option.
Click OK.
Yes you can achieve this by launching a standalone java app which will spawn multiple threads per microservice and start them. You can find a sample code [here]: https://github.com/rameez4ever/springboot-demo.git
Another note to reduce ambiguity:
What was called Run Dashboard in a lot of sources in the past is now called Services.
it's called allow parallel run as of 2018.3 instead of Single instance only
Package the application using mvn package.
Go to the folder where the packaged application jar is stored
Run java -jar [NAME_OF_THE_APPLICATION_JAR]
--server.port=[DESIRED_PORT_NUMBER]
OR
Go to the application root directory
Run: mvn spring-boot:run
-Drun.arguments="--server.port=[DESIRED_PORT_NUMBER]
That way you can start multiple instances of the same microservice at the same time using different port numbers.
Yes.
Goto "Run configurations" combo box, click "Edit Configurations".
Then unchecked "Single instance only" option. Then click "Apply"
For Eureka Server:
1.Run the application without serve.port.
2.Add server.port =9999 in application.properties. Run the application.
Now browse Eureka dashboard, you will have 2 instances running.
I'm sorry if my question seems to be off-topic but I'm new here.
I have to change run configuration eclipse from Java code. I want to run my app with a run configuration (for example: Maven build) and inside of my app I want to edit the current run configuration from maven build to Java application just for a moment.
Is it possible?
Thanks in advance.
Right click on your project and go to Run As and select Run Configurations option in the menu.
A dialog box of Run Configurations will be opened.
Select the required configuration from the left hand side list.
It will open the selected configuration in edit mode.
Make required changes and hit Run.
Getting back into Java coding after being away for a while, downloaded the latest Maven (3.1.1), the latest Eclipse (Kepler), the latest JDK (1.7.0_45), created a new Maven project in Eclipse (using the quickstart archetype, which looks like it defaulted to JUnit 3.8.1), opened AppTest.java, selected "Run As JUnit Test" (not JUnit Plug-in Test), and nothing shows up in the JUnit view.
Shouldn't it at least say something like "Runs: 1/1"? If I change the code in testApp() to "assertTrue( false)", then I don't see a failure (although if I debug, sure enough, an exception gets thrown). If I put a println() in the test, I see its output in the console view. If I run mvn test from the command line, I get a lovely stacktrace and the word "FAILURE!" (and my println() output).
So. Something basic is wrong somewhere, but what?
Maybe you checked the "Show Failures Only" option? (on the same bar as "Rerun Test"). It happened to me :)
I think I repeat your problem. It happens when the JUnit window is opened initially in eclipse (for example I detached the view as separate window and it shows when eclipse starts).
With fresh start (window/view shown) I run tests and don't see anything in it, when I close it and run unit tests (via 'run as') window reopens but now results are shown.
I have to build a Decision Support System, but dont have much experience in Java. So after I connected to MySql with Eclipse (with Connector/J) eclipse started to mess up my other projects. Now, when i try to run other projects in eclipse (that are not related to MySql, ex. Guessing Game) the following error message apperars:
Launch configuration DocsConnectionPropsHelper references non-existing project MySql connection test.
Can anyone help me to resolve this problem please?
UPDATE. it seems that when i press "RUN" elcipse is not running the project that im working with, but other
Your update indicates the issue is actually running the wrong project. To avoid that you may want to close projects you're not working on (right click them in package explorer and select close).
If you do need multiple projects open then when clicking the run icon (which defaults to re-run whatever was ran last among your open projects) make sure you have open in the editor window something that can be ran (and is from the project you want to run).
Then click the drop down arrow to the right of the icon. This will open up a small menu with options to change your build configurations or how it should run your program (i.e. as an application or on a server).
To solve the problem:
-click right botton on the project package you want to work on (run)
-choose Run As
-choose Run Configurations...
-choose DocsConnectionPropsHelper - if in the Project box you see not correct title just remove it. Also remove anything what is in the Main Class box.
-click Apply
-the best option is to close Eclipse and reopen it to make sure that all the settings were configured
It worked for me. Hopefully it will work for you too.