Testing an AppCode Intention Plugin Follow
Answered
I would like to write some tests to support a plugin that I am building but the documentation refers to classes which the AppCode SDK doesn't seem to contain. I'm using AppCode specific APIs so I can't use a different SDK.
I would just like to test that applying my intention will change the PSI tree as I expect. Does anyone know how to get started with writing a test for an AppCode plugin?
Please sign in to leave a comment.
Sean, we don't have publicly available framework to test AppCode plugins with.
But you can build your own: Inherit from PlatformTestCase, in setUpProject open a test xcode project using ProjectUtil.openOrImport(xcpdeprojFile, null, true), then test as usual (see CodeInsightTestFixture)
Thanks Anton. I'll give it a go :)
I've tried what you suggested with some success but I've run into a couple of problems.
I have inherited from PlatformTestCase and overridden setUpProject where my code looks like this:
From the examples I've seen I should be doing something like this:
I've checked myFixture.getAvailableIntentions() and it is always empty (even though my plugin always returns true for isAvailable).
I assume the problem is that I'm creating a project using ProjectUtil.openOrImport but the fixture is creating its own project and when I use configureByFile() it is configuring it to the wrong project.
So my question now is, how do I get my CodeInsightTestFixture to work with my opened project? Or, if I'm going about this wrong, is there a small example you could show me to help get me started?
Note: I've tested the plugin manually and I can run my intention.
Many thanks!
Sean, apologies for the delay, was on vacation.
I think you need to add the file to the xcode project first. Try something like
BTW, here is a request for AppCode testing framework OC-15202 (not in short term plans though).