Reputation: 1360
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
Upvotes: 2
Views: 1512
Reputation: 36
For IntelliJ you need to add your System Property -Dtest=test to Gradle VM options within Settings > Build, Execution, Deployment > Build Tools > Gradle
Upvotes: 1
Reputation: 123996
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.
Upvotes: 2