openrewrite / openrewrite/rewrite-testing-frameworks

ParameterizedRunnerToParameterized update to account for test class inheritance

Open
#91 5 comments 0 reactions 1 assignee View on GitHub

@MBoegers is already working on this.

Since Jun 18, 2024.

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

Description

Discovered while applying JUnit4To5Migration on Antlr

For tests classes that inherit from a superclass and have a constructor which invokes the superclass constructor:

  • compare super constructor parameters with the MethodSource parameters
  • modify super constructor if necessary
  • add init method to class and superclass if necessary

before:

public class BaseRuntimeTest {
        public BaseRuntimeTest(RuntimeTestDescriptor descriptor, RuntimeTestSupport delegate) {
		this.descriptor = descriptor;
		this.delegate = delegate;
	}
}
public class TestPerformance extends BaseRuntimeTest {
	public TestPerformance(RuntimeTestDescriptor descriptor) {
		super(descriptor,new BaseGoTest());
	}
}

after:

public class BaseRuntimeTest {
        public BaseRuntimeTest(RuntimeTestSupport delegate) {
		this.delegate = delegate;
	}

	public void initBaseRuntimeTest(RuntimeTestDescriptor descriptor){
		this.descriptor = descriptor;
	}
}
public class TestPerformance extends BaseRuntimeTest {

	public TestPerformance() {
		super(new BaseGoTest());
	}

	public void initTestPerformance(RuntimeTestDescriptor descriptor) {
		initBaseRuntimeTest(descriptor);
	}
}

e.g. Antlr4-TestPerformance

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.