Action and Inspection (LightCodeInsightFixtureTestCase) tests work in IntelliJ, but not in ant
I have tests for Inspections that mark errors (like ambiguous commas, parentheses or missing end of expression) and testing the New File action. Both test classes extend LightCodeInsightFixtureTestCase and their test cases work in Intellij, but not run with ant. I need them to run with ant as I'm using ant to do the build on travis-ci.org.
Here is the action test:
package org.elixir_lang.action;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import org.elixir_lang.psi.ElixirFile;
import java.io.IOException;
/**
* @see <a href="https://confluence.jetbrains.com/display/IntelliJIDEA/Completion+Test">https://confluence.jetbrains.com/display/IntelliJIDEA/Completion+Test"</a>
*/
public class CreateElixirModuleActionTest extends LightCodeInsightFixtureTestCase {
public static final String TEMPLATE_NAME = "Elixir Module";
public void testCamelCaseAliasIsLowerCaseUnderscored() throws IOException {
ActionManager actionManager = ActionManager.getInstance();
CreateElixirModuleAction elixirNewFileAction = (CreateElixirModuleAction) actionManager.getAction("Elixir.NewFile");
// @see https://devnet.jetbrains.com/message/5539349#5539349
VirtualFile directoryVirtualFile = myFixture.getTempDirFixture().findOrCreateDir("");
PsiDirectory directory = myFixture.getPsiManager().findDirectory(directoryVirtualFile);
ElixirFile file = elixirNewFileAction.createFile("FooBar", TEMPLATE_NAME, directory);
assertNotNull("Expected CreateElixirModuleAction.createFile to create an ElixirFile", file);
boolean ignoreTrailingWhitespaces = true;
myFixture.checkResultByFile(
"foo_bar.ex",
"foo_bar.ex",
ignoreTrailingWhitespaces
);
}
@Override
protected String getTestDataPath() {
return "testData/org/elixir_lang/action/create_elixir_module_action_test";
}
}
and the error when run with ant:
[junit] Testcase: testCamelCaseAliasIsLowerCaseUnderscored(org.elixir_lang.action.CreateElixirModuleActionTest): Caused an ERROR
[junit] null
[junit] java.lang.NullPointerException
[junit] at org.elixir_lang.action.CreateElixirModuleActionTest.testCamelCaseAliasIsLowerCaseUnderscored(CreateElixirModuleActionTest.java:25)
[junit] at com.intellij.testFramework.UsefulTestCase.access$001(UsefulTestCase.java:81)
[junit] at com.intellij.testFramework.UsefulTestCase$2.run(UsefulTestCase.java:298)
[junit] at com.intellij.util.ui.UIUtil.invokeAndWaitIfNeeded(UIUtil.java:2125)
[junit] at com.intellij.testFramework.UsefulTestCase.invokeTestRunnable(UsefulTestCase.java:330)
[junit] at com.intellij.testFramework.UsefulTestCase.runTest(UsefulTestCase.java:314)
[junit] at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:335)
[junit] at com.intellij.testFramework.UsefulTestCase$3.run(UsefulTestCase.java:348)
[junit] at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
[junit] at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
[junit] at java.awt.EventQueue.access$400(EventQueue.java:82)
[junit] at java.awt.EventQueue$2.run(EventQueue.java:676)
[junit] at java.awt.EventQueue$2.run(EventQueue.java:674)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
[junit] at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
[junit] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
[junit] at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
[junit] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
[junit] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
[junit] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
[junit] at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
The ant xml files are here https://github.com/KronicDeth/intellij-elixir/blob/4a5dcb8a55ca9a154c41db830d955e537dda5061/intellij-elixir.xml and here https://github.com/KronicDeth/intellij-elixir/blob/4a5dcb8a55ca9a154c41db830d955e537dda5061/module_intellij-elixir.xml and https://github.com/KronicDeth/intellij-elixir/blob/4a5dcb8a55ca9a154c41db830d955e537dda5061/idea.xml. I assume I messed up setting up IDEA correctly for ant.
请先登录再写评论。
I refreshed (https://github.com/KronicDeth/intellij-elixir/commit/c9638b8c6af1e5f613b2346c0fba088993f740f5) the list of jars in from the idea tarball fileset and the CreateElixirModuleAction test no longer fails, but the overall tests now fail with an error:
This happens at the very end of the run when all tests have passed and clean up is occurring for the enture junit task.