IntelliJ 14 Gradle task in Test Runner - intellij-idea

Upgraded to IntelliJ 14.0.1 One of the big new features I was looking for:
"If you run tests via a Gradle task, the IDE offers you the standard Test Runner instead of the console output." (Source: https://www.jetbrains.com/idea/whatsnew/#buildTools)
I right click on the Gradle Task to run our Integration Tests:
However, I see the results of the test still going to console output, not to the Test Runner:
Has anyone been able to get this new feature in IntelliJ IDEA 14 to work?
Thank you in advance,
Philip

Looks like IntelliJ looks for a task named "test" rather than a task of type Test.
https://github.com/JetBrains/intellij-community/blob/master/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/GradleTestsExecutionConsoleManager.java#L191

Rename the test task to unitTest and then create a wrapper that runs both:
// Rename test to unitTest
tasks.test.name = "unitTest"
// Wrap and run both
task test(dependsOn:['unitTest', 'integrationTest'])
If you only want to run integration tests, just overwrite it:
task test(overwrite: true, dependsOn: ['integrationTest'])
This allows me to run the integration tests in the test runner successfully (at least it works in IDEA 15 EAP but it should work in 14 as well I would think).

I still get this in IntelliJ 2017.1, but specifically when running tests in the gradle buildSrc directory. After digging a while, it turns out that the Gradle API doesn’t expose the test tasks in the special buildSrc directory to Intellij, so IntelliJ doesn’t recognize it as a test.
Workaround: Open another IntellIJ project for the buildSrc directory directory instead of trying to run tests cleanly inside the root project.

Related

where is com.intellij.rt.junit.junitstarter

i use intellij with junit to run tests (new), when i debug my test code for practice, one of the very first lines of code that seems to run is some method called main from package called com.intellij.rt.junit. I've tried clicking on it as well as searching for it open that package or class to see what's inside but i can't find it all. anyone know what it is or where i could find it in intellij and why i can't just access it from the debugger like every other class? i have junit 5.8 installed in maven.
y.bedrov's analysis is quite right.
com.intellij.rt.junit.JUnitStarter is part of IDE. In your case, the IDE is IntelliJ IDEA. You may find the source code in this local path:
/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-rt.jar
then import the jar package into your own project to read the source code conveniently.

IntelliJ Idea Community Edition - how to run all Dart unit tests in a project

If I right click in a test file I can choose to run it. How do I run all the tests in my dart project within IntelliJ.
In VSCode an action exists that scans the project for files labelled _test.dart, is this VSCode / plugin specific or is it possible to do this in Intellij?
In Dart Test run configuration, you can set Test Mode to All in Folder to run all files that end with _test.dart in specified directory (similar to running pub run test path/to/dir in terminal):

How to run sbt task on make project in IntelliJ IDEA?

I'm working on a scalajs project. My workflow is: make code changes, make project in IntelliJ, go to sbt and run fastOptJS task to produce js file, go to browser and test. I would like to remove the step of manually running fastOptJS task in sbt and make that happen automatically when I make project in IDEA. Is there any way to do that?
UPD: It would be also nice to keep sbt running between fastOptJS calls, cause it takes time for sbt to start.
You can simply start the JavaScript compilation with the sbt watch mode.
Select Run | Edit configurations... and add a new SBT Task by pressing the green plus. In the field "Tasks:" define ~fastOptJS and then run the new configuration.
It will compile again whenever you have changed something.
This should be the workaround for your propose, instead of use "Make Project ( Ctrl + F9 )", you can create a run in IDEA and configure an external tool as the image shown, where you can run the fastOptJS task in sbt.

IntelliJ 14 + gradle issue with system properties in test

This is snippet from my build.gradle file:
test{
systemProperty "test", "test"
}
Then I have my test code which looks like this:
#org.junit.Test
public void test(){
Assert.assertEquals("test", System.getProperty("test"));
}
And when I run this test from command line it is passing. If I choose in gradle window task test and click right mouse button and then select run this test also pass. However when I go to test itself and select run on method name it does not pass. It looks like in the third case IntelliJ completely ignored gradle context. Is there something that can be done to make this test work when running directly from IDE? Thanks in advance for reply. Gradle version 2.3.3 and IntelliJ 14.0.2
IntelliJ doesn't currently understand such configuration. To fully solve this category of problems, IntelliJ will need to use Gradle as its underlying build/execution engine, like Android Studio already does today. Until this happens (or support for this specific use case is added to IntelliJ), you'll have to define the same system property in the IntelliJ run configuration (template).
If you use the IntelliJ project generation approach (gradle idea), you can (with some effort) make Gradle generate such a run configuration (template). This is something we do for Gradle's own build.
For IntelliJ you need to add your System Property -Dtest=test to Gradle VM options within Settings > Build, Execution, Deployment > Build Tools > Gradle

Running TestNG Test in IntelliJ

After running Rebuild Project successfully in IntelliJ 13.1.3 Ultimate IDE, I opened my Test NG test file.
When right-clicking on the file, I don't see any option to run the test.
How can I run an TestNG test in IntelliJ 13.1.3?
This question is similar, but it's from 2012 with an unaccepted answer.
Yes you can!
Сheck the folder that contains the test classes whether marked as Test Source Root. In another case see whether installed TestNG-J plugin.
Update:
There are 3 possibilities in the new Intellij 2017.2 to run a testNG test.
You can click on the module (project) name >>Run>>All Tests(TNG). Be careful as there are 2 'All Tests' options. The second option is the one you need. It carries a testNG logo. This way you can run all your testNG classes in parallel
The second possibility is to run a single TestNG class. Righ click the class name in the package explorer and choose 'Run Test' If your class is a testNG class, by default, the test will run as a TestNG test.
This option is my favourite as it gives me a lot of control over my tests. Install this 'Create TestNG XML' plugin. Once installed. if you right click on your module name, you will see a new option called 'Create TESTNG XML' and you will be able to directly use that option to run your TestNG tests, giving you a lot of flexibility.
It could be that a plugin that you need is disabled.
Make sure the testNg plugin is enabled.
I noticed this plugin wasn't enabled,
and as soon as I turned it on, everything started working.