Skip to content

Latest commit

 

History

History
56 lines (35 loc) · 2.11 KB

File metadata and controls

56 lines (35 loc) · 2.11 KB

java-spock-example

Github Actions Status

Spock Logo

Spock Logo

An example project testing out features of the Spock testing framework with a SpringBoot application.

Running the tests

Run the tests using the Gradle wrapper:

./gradlew test

This will execute both JUnit5 unit tests and Spock specs. The test logger has been configured to print all tests and their status.

$ ./gradlew test
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

> Task :test

LoadContextSpec > when context is loaded then all expected beans are created PASSED

HelloControllerSpec > when get is performed then the response has status 200 and content is 'Hello world!' PASSED

StarFleetShipResourceSpec > when get is performed then the response has status 200 and content is list of strings PASSED

ExampleJunitTest > when_listOfStrings_then_Passes() PASSED

ExampleJunitTest > when_listOfStrings_then_Fails() SKIPPED

BUILD SUCCESSFUL in 2s
5 actionable tasks: 2 executed, 3 up-to-date

Contributing

Please make sure to use a pull request to add code. Any contributions are welcome! The goal is to experiment implementing Spock tests against a SpringBoot RESTful application.

This Baeldung tutorial details different Spring Tests that can be implemented and their use.

The Spock docs detail use of the spock-spring library to integrate Spock with Spring Tests.

NOTE: All Spock spec files should be placed under src/test/groovy in order for them to compile and run!

References

  1. Spring Boot
  2. Spock Framework