Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6847837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:47:38+00:00 2026-05-27T00:47:38+00:00

Is there a way to document testNG testcases so that the documentation can be

  • 0

Is there a way to document testNG testcases so that the documentation can be automatically generated? I would imagine something like:

@Description("This testcase checks, whether the system is alive")
@Step("Check whether services are running")
@Step("Try to access the system webpage")
...
@Test(groups={"sanity"})
public void checkStatus() {
...
}

I have considered two options: custom annotation processing and writing my own doclet for javadoc. Before I try any of these options, I would like to know, whether there is a standard way of doing it. I would definitely like to reuse current testNG annotations, especially the grouping of the tests.

Last but not least, I would like to mention that I want to use this approach only for system level tests (NOT unit tests), which I quite complex and where it is not so easy to say what the test does just from the test name or its code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:47:38+00:00Added an answer on May 27, 2026 at 12:47 am

    Finally, I figured it out myself. I use javadoc combined with a little bit of annotation processing (just to distinguish the testcase groups). I use a custom doclet, which first builds the list of testcases in the following way:

    private MethodDoc[] getTestMethods(RootDoc root) {
        List<MethodDoc> result = new ArrayList<MethodDoc>();
        for (ClassDoc c : root.classes()) {
            for(MethodDoc m : c.methods()) {
                if (isTest(m))
                    result.add(m);
            }
        }
        return result.toArray(new MethodDoc[0]);
    }
    
    // simplified test detection
    private static boolean isTest(MethodDoc m) {
        for(AnnotationDesc a: m.annotations()) {
            if (a.annotationType().name().equals("Test"))
                return true;
        }
        return false;
    }
    

    Then, for each test I retrieve the set of groups:

    static Set<String> getMethodGroups(MethodDoc m) {
        Set<String> result = getGroups(m);
        result.addAll(getGroups(m.containingClass()));
        return result;
    }
    
    static Set<String> getGroups(ProgramElementDoc m) {
        Set<String> result = new HashSet<String>();
        for(AnnotationDesc a: m.annotations()) {
            if (a.annotationType().name().equals("Test")) {
                for(ElementValuePair ev : a.elementValues()) {
                    if (ev.element().name().equals("groups")) {
                        String value = ev.value().toString();
                        StringTokenizer tokenizer = new StringTokenizer(value, "{}\", ");
                        while (tokenizer.hasMoreElements()) {
                            result.add(tokenizer.nextToken());
                        }
                    }
                }
            }
        }
        return result;
    }
    

    The rest is just standard doclet processing. In addition, I found out that I can use custom tags directly in javadoc, e.g.

    /**
     * Some description
     * @Step Step 1
     * @Step Step 2
    */
    void someMethod() {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just like in JavaScript : opener.document.getElementByName jQuery: ?? Is there any way to get
Is there any way to print an OOXML document (.docx file) without having MS
Is there any way to save the state of vim settings with a document?
Is there any way to follow a URL in JavaScript without setting the document.location.href
Is there a way to access the DOM of the document in an iframe
is there a way to join 2 NodeLists returned by 2 calls of document.getElementsByTagName?
I just wonder there a way to display the files in document directory with
I am generating a document from HTML. Is there any way to force the
I was wondering if there was a good way to monitor a document library
Is there any PHP PDF library that can replace placeholder variables in an existing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.