Ok, I think I have this figured out.
I placed these two lines in my project and refreshed everything and now I have a “:run” task :
apply plugin:'application'
mainClassName = "qa.webdriver.tests.GoogleTest"
I am not sure how I had it working before without these two lines, but this seems to have something to do with it I think???
I get this error , which suggests to me that I need to make a test suite class with a main method in it:
:runjava.lang.NoSuchMethodError: main
Exception in thread "main"
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':run'.
> Process 'command 'C:\JDK1.6.0_31_x32\bin\java.exe'' finished with non-zero exit value 1
Now, I just discovered that Gradle can’t run the typical JUnit test suite, like this, probably because it doesn’t understand the annotations and works only with a main method??
@RunWith(Suite.class)
@SuiteClasses({ GoogleTest.class })
public class AllTests {
// nothing yet
}
And so, my final solution was to invoke via JUnit to run the test suite class like this:
//@RunWith(Suite.class)
//@SuiteClasses({ GoogleTest.class })
public class AllTests {
public static void main(String[] args) throws Exception {
JUnitCore.main("qa.webdriver.tests.GoogleTest");
}
}
The unfortunate side effect of this is that when I run the project from Eclipse, eclipse doesn’t show me the STOP button that it normally shows me during tests.
So, my ultimate goal might be to move my JUnit test over to the Gradle “test” location and try to get gradle to generate my JUnit results at “build/reports/tests/index.html” .
I am not sure how I am going to do this but I will start experimenting.
Can anyone answer me on how this can be more nicely integrated in Eclipse?
I’ll figure it out eventually, but it will take a while.