Provides support for the amazing Spock testing framework.
Inspired by the Spock Framework Enhancements plugin which is not actively maintained, and does not fully function in the newest IntelliJ versions due to breaking API changes.
- Validation of block names, their order and completeness (e.g. invalid blocks, missing
then
blocks, etc.)
In IntelliJ, go to Settings -> Plugins
and search for spock
in the Marketplace.
For more details, see the plugin page.
- Generate a private key and a signing certificate. Refer to the official documentation.
- Define environment properties.
export INTELLIJ_COMMUNITY_SOURCES = "A path to checked out GIT source codes of the IntelliJ Community" export INTELLIJ_CERTIFICATE_CHAIN = "The content of the certificate" export INTELLIJ_PRIVATE_KEY = "The content of the private key" export INTELLIJ_PRIVATE_PASSWORD = "The password to the private key" export INTELLIJ_PUBLISH_TOKEN = "The token for plugin publishing to JetBrains Marketplace"
- Run
gradle runIde
to execute an IntelliJ instance with the plugin installed. - Run
gradle buildPlugin
to build the plugin and prepare the distribution ZIP archive.
Verifies the plugin, its configuration and binary compatibility.
gradle verifyPlugin
gradle signPlugin
- Increment the version in build.gradle.kts
- Update
- Run
op run -- gradle build verifyPlugin signPlugin publishPlugin
All the signing credentials (key, certificate, password) are configured via environment variables (see the build.gradle.kts file).
To avoid storing plain text secrets on the filesystem, 1password CLI can be utilised to inject the credentials to the Gradle process.
op run -- gradle signPlugin
A green run
icon appears when a spock block is present in a method
- See the
org.jetbrains.plugins.groovy.ext.spock.SpockTestFramework
class - See the
plugins/Groovy/lib/Groovy.jar!/META-INF/spock-support.xml
To obtain debug
logs generated by the plugin:
- Go to
Help -> Diagnostic Tools -> Debug Log Settings
. - Enter
io.github.lobodpav.spock
into the text area. - Open the
build/idea-sandbox/system/log/idea.log
to see the logs.
See https://plugins.jetbrains.com/docs/intellij/ide-infrastructure.html#logging for more details.
Write actions (such as creating an editor for a loaded file in a test) must be executed on the UI thread only.
To perform a write action in a test, wrap your code inside the Application.invokeAndWait()
closure.
ApplicationManager.getApplication().invokeAndWait {
WriteCommandAction.runWriteCommandAction(project) {
// Your code goes here
}
}
See IntelliJ threading rules document for more details.
According to several answers on the IntelliJ community, instead of UI tests developers should test the business code instead.
For example, rather than testing a custom File creation action by showing a UI dialog and interacting with it, the Action itself should be unit tested.