Independently Testing Annotators

I would like to test annotators in an isolated way without worrying about other annotators. It seems like I test inspections independently, but with annotators I can only vary the level. This makes writing tests difficult because I have to filter out irrelevant annotations that may or may not change over time. Is there a way I can configure the editor to or test fixture to disable or enable certain annotations?

3 comments
Comment actions Permalink
Official comment

If this is about disabling annotators _not_ provided by your plugin, then you could run your annotator "manually" with something like this:

AnnotationHolderImpl holder = new AnnotationHolderImpl(new AnnotationSession(psiFile));
MyAnnotator annotator = new MyAnnotator();
annotator.annotate(element, holder);

 

Comment actions Permalink

In your annotators, you can create a configuration -- something like a set of booleans -- that you check before the annotation runs.  The default startup for the plugin can turn them all on, but your tests could only turn on the ones you actually want to use for that test (or turn off the ones you don't want to use).  It doesn't require any support from the test fixture; just your own code.

0
Comment actions Permalink

Thanks Yann,

It's actually about disabling annotators within my plugin, there are some that correlate (a mistake in one part of the file, can cascade else where and not be immediately obvious what the problem is). I just want to have clean tests where I don't have to worry about other annotations, that may or may not be there.

0

Please sign in to leave a comment.