I want to run JUnit tests for my Play 2.4 application within Intellij IDEA 14.1.4 to leverage full JUnit integration.
The tests are executed fine when I create a new JUnit run configuration. However on every test run a full SBT build is executed delaying the tests for around 30 seconds.
If I remove Make form the pre-launch steps in the JUnit run configuration the tests are executed directly without a full sbt build but then any code changes in test and application code are not picked up by IDEA. Even when the play is running with auto-compile on file changes IDEA doesn't pick them up for the tests.
Edit 07/09/2015
I've also exchanged Make with an SBT Action test:compile which only opens up a SBT console loading the project and stops with a prompt. It's not executing the action test:compile and therefore not starting the test at all.
What do I have to change in run configuration and/or project settings to get a fast and seamless JUnit integration for Play projects in IDEA?
Finally found the answer myself when digging through issue tickets of idea-sbt-plugin.
Exchanging Pre launch Step Make with SBT Action test:compile was the right way to go. However the SBT Plugin expects the default sbt shellPromt >. Play projects however define their own custom promt as [projectname] $.
I had to add the following line to build.sbt to get the SBT action to work.
shellPrompt := (_ => "> ")
Related
Using Intelliji Community Edition 2022.03 on windows 11, working with Maven 3.6.3 and Java-8.
Been experiencing strange issue: I cannot run single Junit||Blueprint test if that test has problem, the IDE always try to build the whole test file and then failed at that single problematic test. So the situation end up being I have to run all the test successfully in order to run single test. I am sure it is related to my local environment, because my colleges have no such problem we have everything the same. and I also have no such problem in linux VM.
I have tried
install unintall different versions of IDE
Modify test to not build before run, works, but if I change code, no auto detection, so barely
Any wise men got some ideas please ?
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).
Now that I am using gradle for all of my new development, I'm running into issues with BuildShip features I really don't want.
For instance, when I hit the Run hotkey when I have a unit test open in Eclipse, I only want it to run as a JUnit test, alone. But Gradle has inserted its own hooks and option, which means extra clicking or keypresses beyond the one-stroke hotkey I have assigned to Run that I can tell it I want JUnit. (The gradle test option actually runs all tests, which takes minutes.).
Question: Is there a way to remove this hook in gradle without diving into the source code and ripping out functionality myself?
This isn't the only interference (interfering with run last is another), but it's my #1 annoyance about BuildShip.
Essentially, I want this popup to stop happening.
Indeed you cannot change the available launchers prompt but you can change the default hotkeys related to each launcher and directly use the one you prefer.
From Windows > Preferences > General > Editor > Keys you can get the list of available hot-key mappings. Filter the (long) list by typing test as show below:
As you can see you have several mappings for running JUnit tests: Gradle, JUnit runner, Maven.
The default configuration for JUnit runner is Alt+Shift+X,T, not really user friendly I would say.
I changed it to a more concise Alt+U down in the Binding option and applied the changes. Now you can run any JUnit test on its open editor windows without any prompt, simply type Alt+U and the JUnit runner will be triggered automatically for that single unit test.
This is a major usability annoyance in Eclipse+Buildship. I perform the following steps every time Buildship upgrades to get rid of that annoying popup, and also avoid the (for me, useless) Gradle test process when what I really want is for the last test to run while I am not in that particular class. Admittedly, this is invasive, but it works while keeping the "good" parts of Buildship.
Open up the plugins folder and look for the org.eclipse.buildship.ui_*.jar. (I do this on a Mac, which requires showing the contents of the Eclipse.app first.) Open the .jar file in some zip file editor which can modify files within the zip file (I use BetterZip on Mac, I think Winzip and 7Zip probably work too.) Edit the plugin.xml file.
This is for the new Photon 4.8 release of Eclipse. Remove (or comment out) the following two sections:
The <command> element with id="org.eclipse.buildship.ui.shortcut.test.run"
The <extension> element with the comment <!-- "Gradle Test" entry in the "Run as... " context menu --> above it (about 30 lines)
Save the file, which should be noticed by BetterZip/Winzip and let it update the .jar file with the changed content. Finally, eclipse needs to be restarted with the -clean switch so that it does not use a cached copy of the jar file. For example, on Mac:
cd /Applications/eclipse-jee-photon-R-macosx-cocoa-x86_64/Eclipse.app/Contents/MacOS
/.eclipse -clean
Buildship will now no longer bother you with that popup or run the Gradle test within Eclipse, because the UI entry points have been removed. Unfortunately, on the next update of Buildship you need to repeat the process again on the new jar.
I need to prepare a reporting system which will be displayed the code parts are used and not used by the application and in this particular case I'm going to use EMMA. However there will be no any test code next to project and emma will scan only the methods and give such a report like "20% are not using, %80 are in use" etc...
Is this possible?
If yes how should I configure ant without junit? (Please share sample ant code)
Do I need to make something additional to work with jenkins?
I will try to provide an answer after all even though you didn't tell what exactly you have and need.
Step 1. The first thing to do is to configure Hudson. First step I did was to download hudson war file and run it.
Step 2. What I did here was to start it via java command line and configure the plugins that I need. In your case the plugins are svn, git and android emulator. See below how to configure Hudson.
Configure Hudson Link 1
Configure Hudson Link 2
Next, I downloaded tomcat and I configured the web.xml file from webapps/hudson/web-inf to link to the hudson home just created earlier.
Now, once you managed to run hudson properly, you can start configuring hudson and next the jobs.
Step 3. Configuring Hudson. You start by configuring Hudson, by setting up the plugins you need, like Apache Ant, Android Emulator, etc.
Step 4. Configuring jobs. You have two type of jobs: normal and test.
See below a printscreen for the required configuration.
Common things for both jobs is the repository URL of your online URL, SVN, Git, etc.
A printscreen for a normal job can be seen at:
For the test job on the other hand you have to configure a bit more. You start by configuring the build environment. If you installed the Android Emulator plugin you should see options " Run an Android emulator during build". This has to be checked together with some other information. A small tutorial can be found here. I would say it is pretty similar.
Android on Hudson.
Once you achieved this, further on you configure ant. Here, you check the Ant version to be one that you set before in the general settings section and, as for the targets, I used the following option:
"clean-set-absolute-tested-path emma instrument nodeps verbose-output-file-for-emma install test fetch-test-report".
Now, in order to see the coverage reports, I used a plugin that allows you to publish the coverage reports as an HTML page and this option can be found at the post-build actions step. For a better understanding see the image:
Step 5. Configuring the xml files.
Now, once hudson is done, further on you start configuring the project in eclipse. You start by creating a test project for your app(I hope you know how to do that) and after that you create the files ant.properties, build.xml and project.properties.
At first, you create the build xml and the ant properties files for the library.
An example of a build xml for the library can be found at:
http://pastebin.com/WiD2Y6j4
Also, the ant.properties for the library can be found at:
http://pastebin.com/cpuGVDhL
Further on, you need the configuration for the test app. Build xml:
http://pastebin.com/yjC8TViT
Ant properties:
http://pastebin.com/5STqMV6b
Once you have committed your code and run the jobs you created before, you should be able to see the html report for your code, classes %, methods % and even what your logic tested. However, from my experience the latter(logic testing) has not proven to be quite an exact science.
Hope it helps. That's pretty much the configuration we use at my work. So far was successful.
I have set up eclipse to work just as I want with my java web app using the following instructions : https://stackoverflow.com/a/6189031/106261.
Is it also possible to get unit tests to be run as part of the auto build, without running a maven install (or test). So I make a change to a class, the tests get run, and if a fail occurs I get a some sort of indicator. Without needing to manually run maven test.
There are several ways to achieve this, all with their own limitations:
You could set up a CI server which builds your project every time you commit a new version. Very reliable but not really "real time"
You can add your own builder to the list of builders (project properties -> Builders), for example an Ant builder which runs "ant test" or something. This builder gets invoked every time you save. Every time. That means Eclipse will become a total slug unless running your unit tests takes less than a few milliseconds.
You can use one of the plugins mentioned here: Is it possible to run incremental/automated JUnit testing in Eclipse?