In this tutorial we saw how to use the Spock testing framework to test Java code. We also saw how IntelliJ IDEA can help us to write and run tests.
Spock is powerful and has even more to offer than we've looked at here. We've only touched the surface of what Spock can offer. We've seen the basics of a test, we've seen how to use labels to define tests, we've seen the power of data driven testing, and we've covered a range of tips and tricks for writing correct and readable tests.
If you want to find out more about Spock, take a look at the excellent reference documentation.
Here are some helpful shortcuts mentioned in the tutorial and video:
|Name||macOS Shortcut||Windows Shortcut|
|- use in the project window to create a new file or directory|
|- use inside a test class to generate a new test method|
|- use inside the |
|Run test class||⌃R||Shift+F10|
|Inline variable or method||⌘⌥N||Ctrl+Alt+N|
|Clone caret above or below||⌥ twice without releasing it, then press the Up or Down arrow keys||Ctrl twice without releasing it, then press the Up or Down arrow keys|
|Find action, use if you don't remember a keyboard shortcut. We used this for "rerun tests"||⌘⇧A||Ctrl+Shift+A|
|Context suggestions. IntelliJ IDEA suggests ways to fix or change the code at the caret. In our case, we used this to generate methods when we called a method that didn't exist yet.||⌥⏎||Alt+Enter|
|Load Gradle/Maven changes||⇧⌘I||Ctrl+Shift+O|
|Open Preferences/Settings dialog||⌘,||Ctrl+Alt+S|
There are links to more information on this tutorial's introduction.