Skip to content

ParameterizedRunnerToParameterized update to account for test class inheritance #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pway99 opened this issue Mar 24, 2021 · 5 comments
Assignees
Labels
recipe Recipe request

Comments

@pway99
Copy link
Contributor

pway99 commented Mar 24, 2021

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

@pway99 pway99 added the enhancement New feature or request label Mar 24, 2021
@sambsnyd
Copy link
Member

This requires openrewrite/rewrite#150

@sambsnyd
Copy link
Member

This has been kicking around since March and we haven't prioritized it. Once we implement openrewrite/rewrite#150 we can revisit issues like this.

@pway99
Copy link
Contributor Author

pway99 commented Jan 11, 2022

Re-Opening given that 7.17.0 has better JavaType information

@pway99 pway99 reopened this Jan 11, 2022
@pway99 pway99 moved this to Icebox in OpenRewrite Mar 1, 2022
@tkvangorder tkvangorder moved this from Icebox to Backlog in OpenRewrite Mar 1, 2022
@tkvangorder tkvangorder moved this from Backlog to Recipes Wanted in OpenRewrite Apr 19, 2022
@tkvangorder tkvangorder added recipe Recipe request and removed enhancement New feature or request labels Apr 19, 2022
@MBoegers
Copy link
Collaborator

The current recipe implementation replaces the constructor with the initialize method. Applying this logic to the BaseTest and deleting the constructor may conflict with other usages. This could lead to failing migrations or builds.

@MBoegers MBoegers self-assigned this Jun 18, 2024
@MBoegers
Copy link
Collaborator

I've implemented a test case to reproduce in ParameterizedRunnerToParameterizedTest and implemented a first version of the required changes in the test methods. Currently the migration of the base class is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Recipe request
Projects
Status: Recipes Wanted
Development

No branches or pull requests

4 participants