Skip to content

Commit 4398ff2

Browse files
authored
Add a doc about the Custom Javadoc Tags feature (#1085)
* Add a doc about the Custom Javadoc Tags feature * Format content * Add pictures
1 parent e625e45 commit 4398ff2

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed
33 KB
Loading

docs/images/utbot_settings.png

24.4 KB
Loading

docs/summaries/CustomJavadocTags.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
## Custom Javadoc Tags
2+
3+
Currently, summaries are hard to read because of formatting issues and a lot of details they contain.
4+
5+
**Goal**: to make test summaries structured and clear.
6+
7+
**Idea**: to structure summary by introducing custom JavaDoc tags.
8+
9+
Tags should start with a prefix "utbot" to avoid possible issues with user (or some plugin) custom tags (if they have
10+
the same names).
11+
12+
**Suggested custom tags (NOT ALL OF THEM ARE USED)**
13+
14+
| Name | Description | Usage example |
15+
|----------------------------|------------------------------------|-----------------------------------------------------------------|
16+
| `@utbot.classUnderTest` | Inline link to the enclosing class | `@utbot.methodUnderTest {@link main.IntMath}` |
17+
| `@utbot.methodUnderTest` | Inline link to the method we test. | `@utbot.methodUnderTest {@link main.IntMath#pow(int, int)}` |
18+
| `@utbot.expectedResult` | Value we expect to get. | `@utbot.expectedResult 4` |
19+
| `@utbot.actualResult` | Value we got. | `@utbot.actualResult 64` |
20+
| `@utbot.executes` | Executed condition. | `@utbot.executes {@code (k < Integer.SIZE): True}` |
21+
| `@utbot.invokes` | Invoked method. | `@utbot.invokes {@link main.IntMath#mul(int, int)}` |
22+
| `@utbot.triggersRecursion` | Triggered recursion. | `@utbot.recursion triggers recursion of leftBinSearch` |
23+
| `@utbot.activatesSwitch` | Activated switch case. | `@utbot.activatesSwitch {code case 10}` |
24+
| `@utbot.returnsFrom` | Statement we return from. | `@utbot.returnsFrom {@code return (k == 0) ? 1 : 0;}` |
25+
| `@utbot.throwsException` | Thrown exception. | `@utbot.throwsException {@link java.lang.NullPointerException}` |
26+
| `@utbot.caughtException` | Caught exception. | `@utbot.caughtException {@code RuntimeException e}` |
27+
28+
## Settings
29+
30+
There is a setting `Javadoc comment style` in the main plugin's `Settings`. It has two options: `Plain` text
31+
and `Structured via custom Javadoc tags` (selected by default).
32+
33+
![Settings](../images/utbot_settings.png)
34+
35+
## View
36+
37+
There are two modes the comment could be shown in IntelliJ IDEA: plain text and rendered view.
38+
39+
To activate rendered mode, click on the toggle near comment.
40+
41+
![Example](../images/utbot_custom_javadoc_tags.png)
42+
43+
## Implementation details
44+
45+
Implemented `JavadocTagInfo` to introduce our custom JavaDoc tags.
46+
47+
Implemented `CustomJavadocTagProvider` and registered it in `plugin.xml` to support plugin's custom tags.
48+
49+
Overrided behavior of `JavaDocumentationProvider#generateRenderedDoc` and registered it in `plugin.xml` to render our
50+
custom JavaDoc tags correctly.
51+
52+
Added a flag `USE_CUSTOM_TAGS` to settings.
53+
54+
After plugin's removal, IDE doesn't recognize our custom tags. It doesn't lead to errors, but highlights tags with
55+
yellow color.
56+
57+
## Feedback
58+
59+
We held a Feature Demo meeting to gather some feedback (16.08.2022).
60+
61+
In general, teammates said that the idea and the way it looks like is good and suggested several things to do:
62+
63+
- Investigate if it's possible to add a link to menu settings or file with stacktrace in comments.
64+
- There is no need in classUnderTest tag because methodUnderTest contains this information.
65+
- Add a tag describing the test intention: check boundary cases, calls of some interesting methods.
66+
- Prepare survey and ask Artem Aliev's team to try the feature and share feedback.
67+
68+
## Test scenarios
69+
70+
Currently, the feature works only for Symbolic execution engine, so make sure the slider is on the Symbolic execution
71+
side.
72+
73+
### Default behaviour (the feature is enabled).
74+
75+
1. Run plugin on any Java project and run tests generation.
76+
2. Check if the comments are generated and pretty formatted.
77+
3. Check that all links are clickable (parts that start with `@link` tag).
78+
79+
### Manual settings (you can choose any comment style – old and new).
80+
81+
1. Go to the `Settings` menu, check that the drop-down list `Javadoc comment style` exists and has two options (Plain
82+
text
83+
and Structured via custom Javadoc tags).
84+
2. Select any option, click OK, run tests generation and check that the option is applied and the comments are generated
85+
according to the chosen style.
86+
87+
### Content
88+
89+
1. First, generate comment with one style, then generate with another one and compare its content. If it differs,
90+
please, provide code snippet and both generated comments. It could differ because currently the
91+
style with custom Javadoc tags is a bit simplified.
92+
93+
### View
94+
95+
1. Check that the comments are rendered well. To do it, click on the toggle near the comment (see post about Rendered
96+
view feature in IntelliJ IDEA).

0 commit comments

Comments
 (0)