Does anyone know how I can skip JUnit tests in IntelliJ when doing a Gradle build like the following command line version? I have searched extensively for a solution but can't find one. I am in the process of converting an existing project to Gradle and need to support many developers that are not familiar with Gradle, some UX, some front end, and some Java. There are many broken Junit tests in the myriad modules and long-term we will fix them. Short term I need all other developers to use the tools they are familiar with to be able to do their job easily.
./gradlew build -x test
The Gradle-Android Compiler settings allow for command-line options but not non-android projects as shown in the IntelliJ settings dialog shown below.
You should be able to run a standard clean build from intellij if it's a gradle project (aka gradle integration in intellij). Then edit the configuration and add at the script parameters : -x test which will run the clean build (or any other task) without running tests.
I am using Intellij IDEA 2019.3 (Community Edition).
You can skip test using following settings.
You can get to this via Gradle panel located at right top corner.
Select task -> Run Configuration -> Right click -> Edit Run Configuration..
From intellij 2021.2 onwards, type the argument directly in Run text
Related
I am using IntelliJ IDEA 2022.1.2 (Ultimate Edition) for multiple services using Gradle and Spock testing. I can currently run each module test coverage just fine. But when I run one module/service, it removes the coverage for the previous testing.
Here is what I am trying:
Select each module in the Project view
Right click and select "Run Test.. with Coverage"
this creates a "whole project" configuration
When I try to run that configuration with coverage, I get the error:
I did try to use the modify options, but I noticed that the "whole project" configuration is in the JUnit section, even though I am using Gradle / Groovy /Spock. Here is a requested screenshot of the "Run Configuration":
I feel like there has to be a way to show a collective code coverage for the selected modules but so far my research hasn't helped.
I have been trying to run junit test but facing this issue constantly. I tried to look for answers on the internet but nothing helped.
]1
If there is an error e.g.
"CommandLineWrapper is ill-suited for launching apps on Java 9+..."
Then, try the following workaround in IntelliJ IDEA:
Run -> Edit configurations -> select the failed running config -> Shorten command line: #argfile (Java 9+) -> OK
For IntelliJ 2019 and above go to :
Settings-> Build,Execution,Deployment -> Build Tools -> Maven -> Running Tests and
Uncheck argLine
I had same issue but it has been resolved by updating the Intellij latest version 2020.3. Now i am able to run the test without any error. Please check below link for latest Intellij versions
https://www.jetbrains.com/idea/download/
I had previously installed zulu and Oracle Java and then switched between the two quite a bit.
I ended up having many JDKs
Here's what helped me.
In intelliJ, go to Run, the Edit Configurations.
In the Run/Debug Configurations window, under Build and run section, select 'Java Bundled'.
To make sure this applies for all tests, click on the edit template icon (the spanner), select JUnit and then in the Build and run section select 'java Bundled'
Make sure all the configurations under JUnit has 'java Bundled' as well
Click Apply and Ok. Try to run the tests now and it should probably work.
For me the problem was that I had some incompatible/old dependencies in my SBT project.
I updated the versions of every 3rd party in the SBT config and running ZIO tests in IntelliJ started working.
For me also, the problem was that I made a change in the dependecies and the dependecy updated was incompatible in the SBT project.
New to java and intellij, pls forgive me if i cannot describe the issue clearly.
Brand new install of intellij, brand new import of the java project.
From beginning, seems the project builds fine in intellij, in the GUI there's that clean/compile/verify/install/... life cycles. I click clean, then install, it triggers the unit test and all passing. Now i go to the project root in the command line, "mvn clean install" also passing.
Now i make a change to a resource file, *.sql which is used for in-memory db setup for unit test. i click clean, then install, still passes successfully.
Now i go to the command line again, "mvn clean install" fails in unit test.
I'm so confused now, either way i'm doing the "clean", what's the cause and how should to fix it pls ?
BTW, after working in visual studio for so long, this java and intellij is giving me heart attacks, why the build system in java is so hard and messy ?
Your project is likely configured differently from the maven pom.xml file. When the two aren't configured the same, you'll have problems. I would guess that some dependency is configured correctly in the IntelliJ Project file, but not in the pom.xml. I usually have the reverse problem. I use only the pom.xml to specify dependencies, and rely on the maven plugin to refresh the project (eclipse).
With IntelliJ, it's been a few years, but I remember the same idea. Try deleting the project file, and importing an existing maven pom file. Then modify your dependencies using only the pom.xml and not IntelliJ's project interface. If the pom.xml is correctly defined, the project import will work first try. That heavily depends upon the previous developer working with the project.
Maven is actually a very powerful (if not quirky at times) build tool, and the differences between execution on command line or "inside" IntelliJ are usually simple to explain.
Please check:
you are running the same version of maven (check command line with -version, compare to intellij setup in settings
you are using the same local .m2 folder (local repo) for maven vs intellij
you are not running with any "Profiles" in intellij (check that none are ticked).
you are not skipping any tests because they end with "IT" (meaning Integration Test)
These are the common reasons for differences.
If you post a log of your failing build we might be able to help more.
ok, my friend found the issue, in Maven settings in intellij, there's a "Runner" page, there's a "Skip test" there. In my case it's checked, so the run in intellij skipped unit test (which should fail) and did all other stuff, made it looks like it's passing.
Still several puzzles to me, but this "Runner" -> "Skip test" fixed the issue.
Pretty upset with intellij.
I have created my first Sbt project and I would like to open Sbt console. Perhaps I make a confusion on what is Sbt plugin. I have scala plugin so I suppose Sbt is embeded inside it since I have Sbt windows.
When I look inside View -> Tool Windows I don't see Sbt console but I see Sbt
Even In Sbt panel, I don't see it
In this blog
https://blog.jetbrains.com/scala/2017/03/23/scala-plugin-for-intellij-idea-2017-1-cleaner-ui-sbt-shell-repl-worksheet-akka-support-and-more/
I find at section 2:
It’s now possible to build projects using SBT (instead of IntelliJ IDEA’s internal build system). As this option is still experimental, it should be manually enabled via Build / Execution / Deployment / Build Tools / SBT / Use SBT shell for build and import:
but I don't see Use SBT shell for build and import checkbox.
Do you have any idea?
You are running IntelliJ 2016.2. The integrated sbt shell and build by shell option is only available from 2017.1. I suggest you upgrade IntelliJ and the IntelliJ Scala plugin directly to 2017.3, where the options you are looking for are available.
You cannot access the sbt console from IntelliJ. For that you must run sbt in a terminal (even within IntelliJ), and once you’re inside the sbt shell type ‘console’ or ‘consoleQuick’ (runs the console without compiling the project you run it at).
I'm facing difficulties in setting up a gradle project. During setting up of the Gradle settings in the wizard,
I am not able to use the default recommended gradle wrapper because it downloads the Gradle and the network connectivity is very bad. So I go with the local gradle distribution which I have installed in my Ubuntu. On refreshing of the gradle project after creation, I always get stuck to this error. When I run the gradle build command through the terminal on the empty project, It works fine.
I have also tried the troubleshooting solutions given by the IDE. But, that made no improvements. Need assistance to solve this problem.
Comment if any additional info required.
As no-one else has chipped in, an approach that should work is to use the Gradle Idea Plugin instead of relying on the build in support Gradle in Idea. In my experience the plugin supports a wider range of Gradle project structures than Ideasupports directly. So you would
Create a Gradle project outside Idea and confirm it all works on from the command line.
Add the Idea plugin to the project
Run 'gradle cleanIdea idea' to generate the Idea project files.
Open up the newly generated project files from Idea and off you go.