run integration test with surefire pre and post integration steps in the configuration
Answered
Is it possible to run a single java integration test from within intellij taking into account the surefire pre and post integration steps defined in the maven pom? I managed to run the complete target from the maven project overview tab, but I can't seem to figure out how to run a single integration test with the complete pre and post integration steps executed as well.
Please sign in to leave a comment.
Hi. Could you please provide a project example?
Complicated, proprietary code and all. I can provide some screenshots, in the hope that helps somewhat. In attach you can see the configuration in pre and post integration test in the maven pom, for the proprietary maven plugin. These executions are run correctly when doing maven verify or maven install. If I run the test in intellij by right clicking and Run Test, the pre and post integration steps are not run, on the default junit form.
I can of course achieve the same thing by manually making a Compound Test, but that's rather less practical than having it work out of the box of course.
Is that more or less enough information or would you need more? If so let me know what you need to explain a bit better
>I managed to run the complete target from the maven project overview tab
Do you mean maven goal from Maven projects tool window?
Is there an issue to run single test using Maven goal? Check also this thread https://stackoverflow.com/q/11395406/2000323.
So what I managed to do was a bit of fiddling around with a composite test that indeed runs a maven goal before the test and after the test.
The point that I am making is that I would like to be able to right click on the test in the IDE and just go Run (or Debug) Test and have the pre and post-integration goals ran for me.
It does not really have a lot to do with running a single test using maven goals, in the sense that I more or less know how to do that, it's just that I am looking for a way to have the IDE do that for me. It already interprets the maven pom so I thought it would be possible, but maybe it isn't ( which is also an acceptable answer ;-))
Does that more or less explain my issue?
Try 2018.3 EAP from https://www.jetbrains.com/idea/nextversion/ and Preferences | Build, Execution, Deployment | Build Tools | Maven | Runner | Delegate IDE build/run actions to maven option enabled. Make also sure all options under Maven | Running Tests settings are enabled.
If it does not work feel free to file a feature request at https://youtrack.jetbrains.com/issues/IDEA with the sample project.
Okay, thanks for the answer, it might take me a day or two to get back to testing this issue (priorities, priorities) but I'll comment and maybe file a feature request then. Thanks for the help.
So, unless I have configured it wrong, what your suggestion seems to be doing when I ask it to run one of the failsafe integration tests by right clicking on the integration test and select Run As Junit test
Did I miss something in the config? Or does this sound plausible and expected and should I file a feature request? A sample project will have to ba an elaborate fake because I cannot submit proprietary code.
>it's just that I am looking for a way to have the IDE do that for me. It already interprets the maven pom so I thought it would be possible, but maybe it isn't ( which is also an acceptable answer ;-))
This sounds to me that that IDE can not know ahead what type of goals there are that needs to be run and what types of Run/Debug Configurations can be used. There request for IDE to automatically create run configurations for such goals seems to be me quite specific especially when there is a solution of compound run configurations or adding Maven goals in Before launch section of run configuration. If you believe there could be a useful feature feel free to file a request describing the exact use-case with a sample project. Thanks.
Before launch is completely true, but after launch is somewhat annoying. I think I can get there with maybe a compound test in combination with a test that has the before launch configured.
I do not agree it is so specific by the way, according to me there is already an awful lot of maven pom parsing going on, this is just an extra parse that takes into account the failsafe plugin's specifics. There is already functionality to load up extra java modules that are defined in maven for example. That is compile time and more visible, that's true, but this is not so different I think.
Anyway, if the message is that we need to use the Before Launch for the pre-integration-phase and then add this test to a Compound test for the post-integration=-phase then that's what I'll try.
There is a request for a separate 'After launch' step: https://youtrack.jetbrains.com/issue/IDEA-132501.
>Anyway, if the message is that we need to use the Before Launch for the pre-integration-phase and then add this test to a Compound test for the post-integration=-phase then that's what I'll try.
See also https://youtrack.jetbrains.com/issue/IDEA-132501#focus=streamItem-27-839710-0-0. Currently I see no more other options, besides mentioned. Please feel free to request a feature. Thanks!