Reputation: 151
Problem:
Error:(15, 10) java: cannot find symbol
symbol: class SpringRunner
Error:(16, 2) java: cannot find symbol
symbol: class SpringBootTest
Error:(12, 47) java: package org.springframework.test.context.junit4 does not exist
Error:(10, 47) java: package org.springframework.test.context.junit4 does not exist
/home/ian/Development/JavaEE/RestCalculator/src/main/java/com/testApp/calculator/ApplicationTest.java
Error:(11, 45) java: package org.springframework.boot.test.context does not exist
Background
I am trying to write a Unit test for a simple spring application. The application is built using Gradle. The following code is my build.gradle.
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'calculator'
version = '0.1.0'
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.10.RELEASE")
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("org.springframework.boot:spring-boot-starter-test")
compile("org.springframework.kafka:spring-kafka:1.3.2.RELEASE")
testCompile('junit:junit:4.12')
compile('junit:junit:4.12')
}
Attached is an image showing showing all the libraries associated with this project, which I believe includes the necessary test libraries.
Question
Why can't my project locate org.springframework.test or org.springframework.boot.test?
Attempts at solution
I have run gradle clean, followed by a build
I have updated the maven central repository
I tried to force the version of org.springframework:spring-* to a higher version (5.0.3.Release)
I tried using gradle-plugin:1.5.9.RELEASE
I figure I must be missing something in my build.gradle, but I am at my wits end as to what it is. Any help is appreciated. Thanks.
Upvotes: 0
Views: 2436