hamvocke / spring-testing

A Spring Boot application with lots of test examples
https://www.martinfowler.com/articles/practical-test-pyramid.html
1.12k stars 440 forks source link

How are the tests run/executed? #10

Closed batchu closed 5 years ago

batchu commented 5 years ago

I'm trying to figure out how to simply execute the test cases. I don't see a junit dependency with "test" scope. I've tried gradlew test and also through the IDE. What's the process to get the test cases going?

Attempts to run all the test cases directly from the IDE throw the following error:

image

batchu commented 5 years ago

testCompile('org.springframework.boot:spring-boot-starter-test') is included in the Gradle build file which pulls in the necessary dependencies so a gradlew clean test --info does list the test cases. However the IDE (Intellij) in this case still doesn't work as expected.

hamvocke commented 5 years ago

I'm not an expert on IntelliJ/Gradle integration but I've handled it this way in the past:

I included the idea plugin in my build.gradle. This allows me to set up my idea project from the command line using ./gradlew idea. Then I could import the idea project into IntelliJ and I was good to go.

There might be a more up to date mechanism by now (I trust the lovely JetBrains folks to have improved their gradle integration massively) but the procedure above always worked well for me.