TestFramework : how to get an InspectionManager

Question:
-


How do you get an InspectionManager, in the context of the TestFramework?


Problem : null == InspectionManager.getInstance(getProject());
-





How to reproduce :
-



The 4th assert below always fails :


2 comments
Comment actions Permalink

Why you need it? I mean what test puropse may single createProblemDescriptor
method there can carry out?

--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Alain Ravet" <alain.ravet.list@wanadoo.be> wrote in message
news:bk71ei$ao3$1@is.intellij.net...

Question:
----------
How do you get an InspectionManager, in the context of the TestFramework?

>
>

Problem : null == InspectionManager.getInstance(getProject());
---------
PsiManager psiManager = PsiManager.getInstance(getProject()); > > works fine, but > InspectionManager im = > InspectionManager.getInstance(getProject()); > > always return null. > ]]>

>
>

How to reproduce :
------------------

>

The 4th assert below always fails :

>

>
> package spike;
>
> import com.intellij.codeInspection.InspectionManager;
> import com.intellij.openapi.project.Project;
> import com.intellij.psi.PsiFile;
> import com.intellij.psi.PsiManager;
> import com.intellij.testFramework.LightCodeInsightTestCase;
>
> public class CantGetAnInspectionManager extends LightCodeInsightTestCase
>
> {
>      public void testCaNTgeTaNinspectionManAGER() throws Exception
>      {
>
>          configureFromFileText("Foo.java", "public class Foo{ }");
>
>          PsiFile             file        =   getFile();
>          Project             project     =   getProject();
>          PsiManager          psiManager  =
> PsiManager.getInstance(project);
>          InspectionManager   im          =
> InspectionManager.getInstance(project);
>
>              assertNotNull( "1. getFile()"       , file      );
>              assertNotNull( "2. getProject()"    , project   );
>              assertNotNull( "3. getPsiManager"   , psiManager);
>              assertNotNull( "4. InspectionManager.getInstance(project)",
> im);
>      }
> }
>
> ]]>

>


0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:
> Why you need it? I mean what test puropse may single
> createProblemDescriptor method there can carry out?

How can you test an inspection if you can't check its output (the
problems it found)?

Alain

0

Please sign in to leave a comment.