madhavd1/vscode-javadoc-tools

Generating javadoc does not work for Test classes

HansenChristoffer opened this issue · 4 comments

Expected Behavior

Javadoc comments gets generated above all methods in the file.

Current Behavior

After trying to use "Javadoc Tools: Generate Javadoc comments for open file" nothing happens. Nothing is generated.

Steps to Reproduce

  1. Open VSCode
  2. Create and/or open your Java project
  3. Make sure project/file structure is as it states in the "Current file structure" header below
  4. Create and/or open your test class
  5. Create and make sure there is one or more @test annotated method(s)
  6. Press: Ctrl+Shift+P
  7. Write javadoc tools: generate javadoc comments for open file
  8. Press enter

Context (Environment)

OS: Windows 10
VSCode Version: 1.62.1
JDK: AdoptOpenJDK 11.0.9.101 Hotspot
Project Dependencies: JUnit 4.11 [Test scope]
Extension Id: madhavd1.javadoc-tools
Extension version: Latest from Extensions
Extension requirements: All fulfilled

Detailed Description

This issue is the same for any type of generating tool with the extension that I've tested, not just with "gen in open file". Could this be because of project/file structure?
This has been tested in a non-test class and it successfully generates comments. Therefore we can conclude it is isolated to test classes, in this case.

Current file structure:

  • src ->
    • main ->
      • java ->
        • io ->
          • pewpew ->
            • app
    • test ->
      • java ->
        • io ->
          • pewpew ->
            • app

Hi @HansenChristoffer ,
I tried and was not able to replicate this.
Can you provide your exact project where you face this issue?

Madhav

I am sorry @madhavd1 for have possibly wasted your time.

I got a bit puzzled why you could not replicate my issue even after giving step-by-step instructions. So, I went back and tried again some more on my end. That is when I figured out that it might not be a bug but a feature or at least it might be expected to work like that from your point of view.

My test cases were obviously not returning anything and were not taking any arguments so your extension did not create any Javadocs for them. I personally still do javadocs even if they do not return or take arguments, that is why I thought it was a bug.

To clarify, your extension does only create javadoc blocks for methods that is either returning a value and/or taking argument(s).
Again, not sure if that meant to be like that or not. But that is why I believed it was a bug because I expected it to still create javadoc blocks.

Edit: My project is a fresh quickstart maven project

Hi @HansenChristoffer , I intentionally left out javadoc comments for methods without any params or returns.
Are you looking to get an empty javadoc string in such case?

I understand. Personally I like to use Javadocs to document all my methods and classes. What they do and potentially what they return and take in argument. But the important part being what the method, function or class does.

That being said, I would like to stress that this is just something I usually do personally. I can understand why you not generate javadocs on methods with no args or return. I just thought I would mention it in case it was a bug or not intended. But now that I know it is in fact intended behaviour then I can understand. It is not much work for me to manually add docs for the non-args non-return methods and also the class.

Thanks for the extension and the work you do!