IntelliJ multi module test coverage - intellij-idea

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.

Related

Run Hybris unit test in intellij Idea community edition

i want to run hybris unit test using intellij community edition like how we do it on eclipse.
I don't want to use Hybris intergation plugin as it was failed to defect the unittest that are present in custom directory. when i try to run the test Intellij native build is triggering but not the ant build. and i am resolving the dependencies whenever intellij throws me build fail with those errors.
Can anyone help me to set this up or guide me through what all necessary steps to follow.
I am using latest version of community edition , Junit - 4 & Mockito for writing unit tests.
Thanks in advance.
I was able to Run the tests once i resolved all the errors that was throwing by intellij.
refer the Image here
Once you click on that run button, you get build errors, once you resolve those build errors then automatically that test will run. if it says shorten the command line then
Please refer this article by Intellij, hope this helps.

Intellij error - test framework quit unexpectedly intellij

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.

"mvn clean install" failed in command line, but passed in intellij

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.

Skip tests in IntelliJ using Gradle

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

IntelliJ Ultimate/PhpStorm, showing code coverage results for Symfony2 project

I'm using IntelliJ Ultimate 11.1 which includes the goodies that comes with the latest PhpStorm.
I'm trying to get some things working with the new Code Coverage feature, but having a bit of trouble getting the coverage to show up in my IDE.
The unit testing is working 100%, I can even run the unit tests in debug mode, and trigger xdebug breakpoints etc, which I think is the most awesome thing since toast.
When I set --coverage-html the HTML coverage report is being generated ok, so it's clear that xdebug and phpunit are working nicely together.
The project is a Symfony2 project, which has it's PhpUnit configuration done in a file app/phpunit.xml.dist.
When I select Analyze > Show Code Coverage Data from the menu, I get a popup looking like this:
I'm clicking the [+] but not sure what I have to select, as the OK button on that dialog box is disabled all the time.
I understand that my Test Suite is defined inside the phpunit.xml.dist file, but not sure how to get IntelliJ to use that to figure out how to display code coverage.
I'd be really thrilled to be able to use this neat feature.
Please check the documentation:
To measure code coverage
Prepare tests manually or have test classes generated.
Create a run configuration of the type PHPUnit.
On the main toolbar, select the PHPUnit run configuration in the Run/Debug Configurations drop-down list and click the Run with Coverage button.
Monitor the code coverage in the Coverage tool window.
Do you use the Run with Coverage button?
I just ran a recent update, and everything started working perfectly!