-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Support dynamic tests with JUnit5/Spock/TestNG/... ("maven-plugin-testing-harness"-like tests) #490
Comments
There are ways to programmatically generate project setups for itf (https://khmarbaise.github.io/maven-it-extension/itf-documentation/usersguide/usersguide.html#_generated_project_setup) And here are some examples: https://github.com/khmarbaise/maven-it-extension/blob/master/itf-examples/src/test/java/com/soebes/itf/examples/mps/MavenProjectSourcesMoreComplexIT.java At the moment ITF does not use a virtual file system (like jimfs etc.) it uses real hard drive... but that might be a good idea to support that.... |
@khmarbaise Ah I see, I wasn't aware of such possibility with ITF. Thanks for sharing! Unfortunately, there is still the need to rely on the By providing a way to use ITF as a library instead of a framework (just calling the library when needed/wanted as I suggested in my initial post) this allows consumers to be as flexible as they want (as long as the exposed methods from ITF are expressive enough of course). If they want to write Spark tests: they can. If like me they want to rely on virtual FS like Jimfs, then they can as long as there is a mechanism to inject objects in the Mojo under test. The laziest approach would be just to provide a way to retrieve the generated Mojo instance so that they can inject the in-memory file system myself through a call to an initially defined setter on the Mojo (even if not ideal). However, since Maven already rely on Eclipse SISU for dependency injection... Then the biggest thing is already there to support what is needed in such scenario. Personnally, I would love to see ITF exposing some methods for quick, easy and flexible setup without having to worry/depend on an opinionated setup imposed by a framework. |
Hello,
I explored this new suggested solution for testing Maven plugins but then I realized it is unable to answer my (specific?) needs (from what I understood so far).
In fact, what I want is very simple: being able to dynamically generate Maven projects (in my case by providing an instance of
MavenProject
built from aModel
). The main goal sought here is to follow DRY principle by avoiding duplicatingpom.xml
files again and again with only a very small difference not always easy to spot most of the time. Well, with ITF andmaven-invoker-plugin
, when the need is to only write few tests then that may be ok... But what about the case where you want to write dozens or maybe even hundreds of tests?The
maven-plugin-testing-harness
framework allows me to do that. ITF not (except if I'm wrong?).Here is an example of (more or less generic) test that I have:
Note: the logic behind the
generateMavenProject()
method implementation may be not trivial at all depending on how complex the plugin's configuration model is. However, the base implementation of the method is the following one:Based on this example, what I would expect from a modern Maven test framework is mainly just to have the possibility to rely on regular JUnit 5 tests with standard annotations like
@Test
,@ParameterizedTest
and so on.So this means: no abstract class like
AbstractMojoTestCase
to extend, just a call like... Let's say randomlyMojoTestExecutor#execute(MavenProject, String)
and that's all! I really think this is achievable.So this would lead to the following result:
But maybe what should be done is simply make some evolutions on the
maven-plugin-testing-harness
framework itself? But in this case then we should consider the fact ITF is only a better alternative to themaven-invoker-plugin
.What do you think?
The text was updated successfully, but these errors were encountered: