Possible to add custom filtering to the unit test output console?

I've added a few console views to my custom language plugin with a header that allows the user to type in a filter string and have the console view contents filtered to include only matching entries (there's also a checkbox that acts as a canned filter to show only debug logging). I'd love to have this same thing available for filtering unit test output, but when I looked at how I might do that, there were just too many layers in between the unit testing plugin SDK and the console view used for displaying unit test results.

Any idea of whether this can be done without having to effectively rewrite major portions of the unit testing framework (which I don't want to do)? If not, should I log an enhancement request for being able to specify custom filtering capabilities on indirect console views like this?

Thanks!

0
4 comments

Hi Scott,

how do you add filters then? It's possible to add custom actions to the toolbar providing them in your test console properties `com.intellij.execution.testframework.TestConsoleProperties#appendAdditionalActions`. Would it work for you?

Thanks,

Anna

0

Thanks for the reply, Anna. It looks like that might work, but I have two follow-on questions.

First, that approach adds the action under the gear drop-down in the main runner toolbar. Ideally the icon would be in the console toolbar on the right of the console window, both for discoverability and convenience. If this is the only place I can currently add the action, though, I can document the option for users.

Second, no matter where the action is found, is there a sanctioned way to apply and clear a filter against its contents? Basically when the user toggles this action, I want to update the console view to show only a subset of output, and when the user toggles it again, I want to show all of the original output.

Thanks again!

Scott

0

I am not especially familiar with the api but looks like you may also try `com.intellij.execution.actions.ConsoleActionsPostProcessor#postProcess`. There you'll have console in the context and you'll be able to change the text in the console according to the user's input

Anna

1

Anna, just a quick follow-up, but the last recommendation worked PERFECTLY for me! Thanks so much for providing the lead.

0

Please sign in to leave a comment.