Support TestNG class level annotations

Open
#1,133 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
testing

Research direction

Start with the TestNG class-level annotation documentation linked in the issue and reproduce the reported "No tests in file" behavior using the Java example. Locate the existing TestNG test-discovery entry point and add coverage for public methods inherited from a class-level @Test while excluding private methods. Done means the tests run and appear in code lenses and the Test panel.

Written by the indexing model from the issue text.

Description

ai-triaged bug enhancement low-priority test-discovery testng

Consider adding support for TestNG class level annotations.

https://testng.org/doc/documentation-main.html#class-level

With TestNG the @Test annotation can be placed on a class instead of the method. In this case all public void methods are considered tests even if they are not annotated.

Example:

@Test
public class TestNGTest {

  public void test1() {
    System.out.println("Test 1");
  }

  public void test2() {
      System.out.println("Test 2");
  }

  private void privateMethod() {
    System.out.println( "Not a test" );
  }
}

Currently there does not appear to be any way to run a test unless it is explicitly annotated. Right clicking and selecting Run just pops up an alert with No tests in file: .... No code lens appear at either class or method level. No tests appear under the class in the Test panel.

Dominant language
TypeScript
Stars
340
Forks
173
Avg merge
1d 2h
Merged PRs (30d)
17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/vscode-java-test

All issues in microsoft/vscode-java-test

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.