openrewrite / openrewrite/rewrite-testing-frameworks
ParameterizedRunnerToParameterized update to account for test class inheritance
Open
@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);
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.