I have a very basic gradle project, and have a test file with main(). The file - "src/test/javaTestRunner.java" is as follows:
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
public class TestRunner {
public static void main(String[] args) {
Result result = JUnitCore.runClasses(TestJunit.class);
for (Failure failure : result.getFailures()) {
System.out.println(failure.toString());
}
System.out.println(result.wasSuccessful());
}
}
The code compiles ("./gradlew classes" and "./gradlew testclasses" works fine). However, I am not able to execute TestRunner, not able to find the correct way to invoke the above class. I have tried the following:
./gradlew test --tests TestRunner ./gradlew test TestRunner ./gradlew TestRunner
"build.gradle" contains the following:
apply plugin: 'java'
apply plugin: 'application'
repositories {
jcenter()
}
dependencies {
compile 'com.google.guava:guava:21.0'
testCompile 'junit:junit:4.12'
}
// Define the main class for the application
mainClassName = 'MyFirstJavaProgram'
Any suggestions.
Thank you, Ahmed.