How can I customize test result tree view actions?

Planned

I have a tests which use special format Markdown files to generate parameters for parameterized tests.

The TestTreeView results in:

 

All navigation from the TestTreeView is to the Java test file which is not relevant for these tests 99% of the time. I got around this limitation for failed tests by adding a file URL with line number in the failed test message which can be used for navigation to the data file. For tests that pass there is no message so this workaround does not work.

I would like to provide actions for test results tree view:

  • double click or enter navigate to the corresponding example location in the markdown file
  • Navigate to Test Data to do the same
  • Leave navigate to source and show source as is

Q1: How can I override double click and enter navigation for test results view?

Q2: How can I override Navigate to Test Data to do the same?

Q3: Can I get the Java test class name (fully qualified if available but not critical) and either the index of the parameter in the parametrized list or the test description used in the results view (such as [Typing Handler: 1]). With that I can navigate to the example in the test data file.

Background details if needed

The format is based on the examples used in CommonMark spec.txt file, augmented to allow arbitrary configuration option on a per-test basis and an extra section per example to provide expected resulting AST.

The options are given as text strings in the Markdown file with mapping done in the Java test file. Most of my flexmark-java library tests are in this format and it is so convenient that I now use them for Markdown Navigator LightPlatformCodeInsightTestCase derived tests.

To help with this format I added functionality to my plugin for navigation, inspections and refactoring of option names to ensure markdown test file and Java class supporting it are in sync.

The caret positions and selection markers are configurable. I use for caret and ⟦ ⟧ for marking selections which do not look like HTML to mardown source and tend to disturb the visual placement of text less than the standard: <caret>, <selection> and </selection>.

Here is a sample, input from expected results is separated by a line with a single . at the start. Options type[], margin[], wrap are all Java test file specific options. In this case used to set right margin, turn on wrap on typing and invoke type() for text given between [].

## Typing Handler

```````````````````````````````` example(Typing Handler: 1) options(type[ ])
⦙text
.
 ⦙text
````````````````````````````````


```````````````````````````````` example(Typing Handler: 2) options(type[ ])
⦙ text
.
 ⦙ text
````````````````````````````````


```````````````````````````````` example(Typing Handler: 3) options(wrap, margin[30], type[ ])
⦙text should wrap onto the next line at right margin of 30
.
 ⦙text should wrap onto the
 next line at right margin of
 30
````````````````````````````````
3 comments
Comment actions Permalink

Hi Vladimir,

there is no possibility to customise actions.

What framework do you use to run tests? The existing approach is to customise messages send from tests to IDEA and implement your `com.intellij.execution.testframework.sm.runner.SMTestLocator` based on that information

 

Anna

0
Comment actions Permalink

Hi Anna,

I am running junit5 tests in non plugin projects and junit4 test cases extending BasePlatformTestCase. The latter seriously hacked the implementation to allow for my gathering actual results for all parameters. So most of the time I catch exceptions from BasePlatformTestCase and fixture methods so I can extract actual results.

I will take a look at SMTestLocator to see what I can do with it.

Thank you very much for the pointer. I think it will work but will be back if I encounter dead ends.

0
Comment actions Permalink

junit 5 could provide url pointers to anything, there are some open bugs assigned to me though, please ping me if you also end up there.

I am not sure that I understood what you say about plugin tests. Code samples would help if would you need my help. Sorry for the inconvenience

Anna

0

Please sign in to leave a comment.