I have below maven java projects:
- com.validator
- com.demoModel1
- com.demoModel2
Validator project contains the validation code and the jar is used by demoModel1 and demoModel2 projects to perform validation. To perform validation, in demoModel1 and demoModel2 projects, I have to write JUnit test cases, but those test cases are similar, except different index for them as parameters. Because of that reason, I have created a parameterized test class named ExecuteSimulation:
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.ArgumentsProvider;
public class ExecuteSimulation implements ArgumentsProvider {}
For now, I have to create this ExecuteSimulation class in both demoModel1 and demoModel2 projects. But I want to reuse the ExecuteSimulation class in both demoModel1 and demoModel2 projects. I tried to put ExecuteSimulation class in com.validator project. If I put the class in the src/java folder of com.validator project, it yields error, complaining that junit dependencies are not found.
If I put ExecuteSimulation class in the src/test folder of com.validator project and try to use it in demoModel1 and demoModel2, both of the project yields errors complaining that the reference of ExecuteSimulation class from com.validator project is not found. I guess it happens because of the location src/test.
In this regard, what will be the proper way to reuse this parameterized test class across different maven java projects?