Search in sources :

Example 1 with JUnitConsoleProperties

use of com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties in project intellij-community by JetBrains.

the class JUnitOpenSourceAtExceptionTest method testStackTraceParseerAcceptsJavaStacktrace.

public void testStackTraceParseerAcceptsJavaStacktrace() throws Exception {
    myFixture.addClass("abstract class ATest extends junit.framework.TestCase {" + "  public void testMe() {\n" + "    int i = 0;\n" + "    int j = 0;\n" + "    int k = 0;\n" + "    fail();\n" + "  }\n" + "}");
    myFixture.addClass("public class ChildTest extends ATest {}");
    final SMTestProxy testProxy = new SMTestProxy("testMe", false, "java:test://ChildTest.testMe");
    testProxy.setTestFailed("failure", "\tat junit.framework.Assert.fail(Assert.java:57)\n" + "\tat junit.framework.Assert.failNotEquals(Assert.java:329)\n" + "\tat junit.framework.Assert.assertEquals(Assert.java:78)\n" + "\tat junit.framework.Assert.assertEquals(Assert.java:234)\n" + "\tat junit.framework.Assert.assertEquals(Assert.java:241)\n" + "\tat junit.framework.TestCase.assertEquals(TestCase.java:409)\n" + "\tat ATest.testMe(Dummy.java:6)\n", true);
    final Project project = getProject();
    final GlobalSearchScope searchScope = GlobalSearchScope.projectScope(project);
    testProxy.setLocator(JavaTestLocator.INSTANCE);
    final Location location = testProxy.getLocation(project, searchScope);
    assertNotNull(location);
    assertInstanceOf(location, MethodLocation.class);
    final JUnitConfiguration configuration = new JUnitConfiguration("p", getProject(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
    final Navigatable descriptor = testProxy.getDescriptor(location, new JUnitConsoleProperties(configuration, DefaultRunExecutor.getRunExecutorInstance()));
    assertInstanceOf(descriptor, OpenFileDescriptor.class);
    final OpenFileDescriptor fileDescriptor = (OpenFileDescriptor) descriptor;
    final VirtualFile file = fileDescriptor.getFile();
    assertNotNull(file);
    assertEquals(5, fileDescriptor.getLine());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SMTestProxy(com.intellij.execution.testframework.sm.runner.SMTestProxy) Project(com.intellij.openapi.project.Project) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) JUnitConsoleProperties(com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties) MethodLocation(com.intellij.execution.junit2.info.MethodLocation) Location(com.intellij.execution.Location) Navigatable(com.intellij.pom.Navigatable)

Aggregations

Location (com.intellij.execution.Location)1 MethodLocation (com.intellij.execution.junit2.info.MethodLocation)1 JUnitConsoleProperties (com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties)1 SMTestProxy (com.intellij.execution.testframework.sm.runner.SMTestProxy)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Navigatable (com.intellij.pom.Navigatable)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1