Search in sources :

Example 1 with AssertionErrorCase

use of com.intellij.testFramework.exceptionCases.AssertionErrorCase in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoFindUsageTest method testLoadSdkUsagesForSdkDeclarations.

public void testLoadSdkUsagesForSdkDeclarations() throws Throwable {
    myFixture.configureByText("bar.go", "package foo; import `io`; type ReaderWrapper interface{io.Rea<caret>der}");
    failOnFileLoading();
    assertException(new AssertionErrorCase() {

        @Override
        public void tryClosure() {
            try {
                assertSize(5, myFixture.findUsages(myFixture.getElementAtCaret()));
            } catch (AssertionError e) {
                String message = e.getMessage();
                assertTrue(message.contains("Access to tree elements not allowed in tests"));
                assertTrue(message.contains("io.go"));
                throw e;
            }
        }
    });
}
Also used : AssertionErrorCase(com.intellij.testFramework.exceptionCases.AssertionErrorCase)

Example 2 with AssertionErrorCase

use of com.intellij.testFramework.exceptionCases.AssertionErrorCase in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoFindUsageTest method testLoadImportedDirectory.

public void testLoadImportedDirectory() throws Throwable {
    myFixture.addFileToProject("bar/bar.go", "package bar; import `foo`; func _() { println(CONST_NAME) }");
    PsiFile declarationFile = myFixture.addFileToProject("foo/foo.go", "package foo; const CON<caret>ST_NAME = 1;");
    myFixture.configureFromExistingVirtualFile(declarationFile.getVirtualFile());
    failOnFileLoading();
    assertException(new AssertionErrorCase() {

        @Override
        public void tryClosure() {
            try {
                assertSize(1, myFixture.findUsages(myFixture.getElementAtCaret()));
            } catch (AssertionError e) {
                String message = e.getMessage();
                assertTrue(message.contains("Access to tree elements not allowed in tests"));
                assertTrue(message.contains("bar.go"));
                throw e;
            }
        }
    });
}
Also used : AssertionErrorCase(com.intellij.testFramework.exceptionCases.AssertionErrorCase) PsiFile(com.intellij.psi.PsiFile)

Example 3 with AssertionErrorCase

use of com.intellij.testFramework.exceptionCases.AssertionErrorCase in project intellij-community by JetBrains.

the class TestSuiteStackTest method testPopEmptySuite_DebugMode.

public void testPopEmptySuite_DebugMode() throws Throwable {
    // enable debug mode
    enableDebugMode();
    assertException(new AssertionErrorCase() {

        @Override
        public void tryClosure() {
            myTestSuiteStack.popSuite("some suite");
        }
    });
}
Also used : AssertionErrorCase(com.intellij.testFramework.exceptionCases.AssertionErrorCase)

Example 4 with AssertionErrorCase

use of com.intellij.testFramework.exceptionCases.AssertionErrorCase in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoPackageClauseStubTest method testParsingPsi.

public void testParsingPsi() throws Throwable {
    GoFile file = (GoFile) myFixture.addFileToProject("bar/bar.go", "package bar; import `foo`; func _() { println(CONST_NAME) }");
    failOnFileLoading();
    GoPackageClause packageClause = file.getPackage();
    assertNotNull(packageClause);
    assertException(new AssertionErrorCase() {

        @Override
        public void tryClosure() {
            try {
                packageClause.getIdentifier();
            } catch (AssertionError e) {
                String message = e.getMessage();
                assertTrue(message.contains("Access to tree elements not allowed in tests"));
                assertTrue(message.contains("bar.go"));
                throw e;
            }
        }
    });
}
Also used : GoFile(com.goide.psi.GoFile) AssertionErrorCase(com.intellij.testFramework.exceptionCases.AssertionErrorCase) GoPackageClause(com.goide.psi.GoPackageClause)

Example 5 with AssertionErrorCase

use of com.intellij.testFramework.exceptionCases.AssertionErrorCase in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoFindUsageTest method testLoadTestDirectoryFromTestFile.

public void testLoadTestDirectoryFromTestFile() throws Throwable {
    myFixture.addFileToProject("foo/bar_test.go", "package foo_test; import `foo`; func _() { println(CONST_NAME) }");
    PsiFile declarationFile = myFixture.addFileToProject("foo/foo_test.go", "package foo; const CON<caret>ST_NAME = 1;");
    myFixture.configureFromExistingVirtualFile(declarationFile.getVirtualFile());
    failOnFileLoading();
    assertException(new AssertionErrorCase() {

        @Override
        public void tryClosure() {
            try {
                myFixture.findUsages(myFixture.getElementAtCaret());
            } catch (AssertionError e) {
                String message = e.getMessage();
                assertTrue(message.contains("Access to tree elements not allowed in tests"));
                assertTrue(message.contains("bar_test.go"));
                throw e;
            }
        }
    });
}
Also used : AssertionErrorCase(com.intellij.testFramework.exceptionCases.AssertionErrorCase) PsiFile(com.intellij.psi.PsiFile)

Aggregations

AssertionErrorCase (com.intellij.testFramework.exceptionCases.AssertionErrorCase)6 PsiFile (com.intellij.psi.PsiFile)2 GoFile (com.goide.psi.GoFile)1 GoPackageClause (com.goide.psi.GoPackageClause)1