Is there a way to unit test plugin action that needs DataContext?
Answered
Hello.
I have developed a plugin File action that extends the JavaCreateTemplateInPackageAction
and I'm trying to unit-test the overridden the isAvailable(dataContext: DataContext)
function.
The test will verify that the action is available only if the user executes it in the src/test/groovy
folder.
Is there a way to create an instance of the DataContext
that will emulate the setup where the user has selected the src/test/groovy
folder in the Project Tool Window and executed the action?
Please sign in to leave a comment.
You can provide “fake”
DataContext
viacom.intellij.openapi.actionSystem.impl.SimpleDataContext
This is what I'm trying to do. Is this way the right way?
If it works, then it LGTM
OK. I was just curious whether I'm doing it more complex than necessary :)