openrewrite / openrewrite/rewrite-testing-frameworks

Recipe to add missing `@Test` annotations

Open
#772 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

recipe
Dominant language
Java
Stars
100
Forks
105
Avg merge
2h 25m
Merged PRs (30d)
9

Description

What problem are you trying to solve?

Find and fix test cases which are forgotten and thus are not executed.

Some heuristics is probably needed to determine if given method is indeed a test case and not some helper method.

This is relevant to JUnit 4+ which uses annotations to determine if something is a test case.
(Possibly other test frameworks use the same approach and the recipe could cover them too).

Describe the situation before applying the recipe

    void testAddition() {
        int result = calculator.add(2, 3);
        Assertions.assertEquals(5, result);
    }

Describe the situation after applying the recipe

    @Test
    void testAddition() {
        int result = calculator.add(2, 3);
        Assertions.assertEquals(5, result);
    }

OSS repro

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.

Research direction

Start by examining the two OSS reproduction pull requests linked in the issue and compare the forgotten test methods with nearby helper methods. Define the heuristics for JUnit 4+ test methods, then implement a recipe that adds @Test only where appropriate and verify that helper methods remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.