Skip maven test phase on local - java

I want to skip tests before installing my java project just on my local since it's taking too much time. It should keep on working on buildserver.
I know that it can be done on command line but I'm using Intellij and when I click on "Install", I don't want it to run tests.
How can I achieve this?

Just click on this button before running the install:
The button might look different or be somewhere else on a different Intellij version. In this case, you can do the following:
Press 2x SHIFT to open the Search Everywhere window and search for Toggle 'Skip Tests' Mode.

Related

Unit tests terminated in Debug mode

I'm using IntelliJ IDEA 15.0.2 (Community Edition) under Windows 7 and Windows 10 Pro, Gradle 2.9, JDK 1.7.0_65. Operating systems installed as guests under VMware Workstation 11.1.3
I have created Android Gradle application with single empty activity and wanted to check how unit test support works. There is a single unit test module ApplicationTest.java created by IDE, it contains only constructor. Right-clicking on [java] folder I created 'All in Module' JUnit3 test configuration.
Tests complete successfully when I Run them, however fail if I Debug the configuration. Failure reason says 'Terminated' (screenshot, IDEA log) which explained in the documentation as 'Test terminated. This status is assigned to tests that were cancelled by clicking the Stop button'. Just want to confirm that I didn't click the Stop button.
Logcat logs don't report any failures, IDE log reports 2 tests passed too. However problem remains as IntelliJ still reports a termination.
Sometimes I also getting 'Test framework quit unexpectedly' error and no tests succeed.
I've done some research and found similar questions, no real solutions mentioned. Have strong suspicion that this is a configuration issue.
What do I do wrong?
Gabor's suggestion seemed to fix this issue for me. On a Mac (and I presume on a Windows machine, but with a different route to get there) go to Preferences:
From the menu bar at the top Android Studio → Preferences
or
Hit ⌘ and , to jump straight to it.
Then in the menu search box type "instant". Uncheck the box that says "Enable instant run..", which looks like the image below.
That fixed it for me; didn't even need to restart/kill ADB.
It seems to be enabled by default, and I use it often to hot-swap changes during development, so I didn't think to turn it off when running Espresso tests.
In my situation, the problem is solved by setting in the test's run configuration:
Shorten command line -> JAR manifest.
To get rid of unit test problems in debug mode, I deleted all test folders in android studio explorer, then I commented three test implementation lines in build.gradle(module) file. Then I changed the combobox in android studio menu (top of the IDE) from "all in app" to "app".
https://i.stack.imgur.com/alPrS.png
In our case the fix (that may not be required in newer Android-versions) was to:
Open Edit Configuration... for All tests (or what ever you renamed it into).
Switch to Debugger tab.
And finally, in Debug mode combo-box, select the Java option, because:
Although we have lots of Native codes,
Android-studio 3.2.1 (which we were using) does not seem to support debugging both (but Java only mode works fine).

Intellij test run history

What I miss the most in IntelliJ compared to Eclipse is the test run history window. Does anything like this exist in IntelliJ? I didn't find it anywhere so far and have looked a few times at least.
In our project we have ~500 integration test cases which take like 5 minutes to run from IDE. Often I have a situation where for e.g. 5 tests fail in 2-3 different classes. I fix something, that should remove failures from first test suite, rerun it to see if it helped and I must rerun all 500 tests to see which classes contained failures earlier. That is really painful. In eclipse I would just lookup those in test history, repair them also and finally run all 500 to check if nothing new camed up.
Is there a plugin out there or do I miss something obvious?
I use IntelliJ 13.
You can right-click a tab with test results and select the "Pin Tab" option from the context menu. Then further test executions will not overwrite this tab, and you can still refer to it to see which other tests you need to fix.
On the current version of Intellij (2016), you have now a way to reimport older test Result. On the runner tab, click on the button "Import test Results", and select the one you want
EDIT : In the latest version, you have a "Recent Tests" action which allow you to see older test result without a need to open the rest windows. Shortcut Ctrl+Shift+Semicolon
You can also click the "Test History" button to see the old tests result.
Not relevant for Idea 13, but in 2021 this functionality is present in Idea.
https://www.jetbrains.com/help/idea/viewing-and-exploring-test-results.html#view-previous
Yes, given that you are using the IntelliJ test runner (rather than running the tests via maven), you can use the Rerun Failed Tests function.
https://www.jetbrains.com/idea/help/rerunning-tests.html
Edit: based on your comment, can I suggest you run the single test you are working on in "debug" mode, this won't erase the history of your compelte test suite, and you can do that in in combination with the Rerun Failed Tests as needed.

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

Cleaning Projects and Servers to see my changes working

Let me explain..
I used to program all day just cleaning projects(Project > Clean) and JBoss server(Right click on it > Clean) sometimes.
Something around 10 times in a day of 8 hours working.
Now I need to do it all the time, otherwise it won't get my code updated.
Is there something that I can do to avoid doing it all the time?
Is it even possible?
You can use 'ant' script to clean and build and link it with Eclipse as Builder.
First create a ant script with a target which will do the clean build.
Now go to Eclipse and right click the project and select 'Properties' and select 'Builders'. Click 'Add' button and select 'Ant Builder'. In the shown dialog , point to the ant file you created. Select 'Targets' and select the targets which you want to run.
Run your server in debug mode, so that it has hot-swap enabled. Then make sure you send each changed file to the server. This can be done either via WebToolsPlatform or using the FileSync plugin. If using ant, this looks interesting
A paid option to increase creativity is JRebel. I haven't used it, and the advice I pointed out above are sufficient for me, but take a look at it as well.
Btw, avoid doing clean that often. It is a slow process.

How to open and run a specific script from the command line in eclipse

I am trying to run an automated suite every day at the same time, so I want to create a task to open eclipse and execute the main script every day. Is there a way to do this from the command line?
Instead of using eclipse for it, use a software that is dedicated for it - continous integration servers are created for it. Check such titles like: hudson, cruiseControl, TeamCity
You are on the wrong path. Instead of trying to automate opening eclipse, executing a main... break the IDE dependency, write a portable build script using Ant or Maven and execute that build script outside the IDE (using a simple cron job or something more elaborated like a Continuous Integration tool but I'm not sure you need a CI tool for now, start with the build script).
So I am assuming that you want to automate something that you run from inside eclipse. if it's a build then I'm with the other guys that using a build script and CI is the way to go.
But in case it's not that use case...
Now, if you are using the "Run.." dialogs to do this you can actually get the command line paths, binaries and arguments that eclipse used to execute.
What you do is open up the debug perspective. Then run your script however you normally do.
Your Process should appear in the "Debug View" at this point.
Either while the process is running or after termination, right click on the process and open up the properties. (you may need to click 1 level down in the tree to get this option)
Under process info, inside of that there is a section "Command Line". This is the exact command line that eclipse executed behind the scenes to run.
you should be able to put this into a script (.bat for windows / sh for *nix) and schedule accordingly.
edit: added in assumptions, changed to use process info terms which is what is on the properties screen.

Categories

Resources