Using Eclipse Java EE 4.5.2 with Buildship 1.0.14
After an “empty” new Gradle project is created with Buildship, it creates, by default, a “LibraryTest” class that fails to build because JUnit 4 is not automatically added to the build path.
Error: “Test cannot be resolved to a type”
Here is the content of the unmodified build.gradle:
// Apply the java plugin to add support for Java
apply plugin: ‘java’
// In this section you declare where to find the dependencies of your project
// Use ‘jcenter’ for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
// In this section you declare the dependencies for your production and test code
// The production code uses the SLF4J logging API at compile time
// Declare the dependency for your favourite test framework you want to use in your tests. // TestNG is also supported by the Gradle Test task. Just change the // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add // 'test.useTestNG()' to your build script. testCompile 'junit:junit:4.12'
So JUnit shows up there, but nothing seems to get it to automatically add the dependency (Refresh, Project->Clean, …). I end up having to do the Quick Fixes to add JUnit manually and add the static import, but I expected this to be automatic.
Is this the expected behavior?