2

Is there a way to run Karate test during maven's integration test phase? It seems that surefire plugin is hardcoded into Karate. I have tried to override it using failsafe plugin but with no luck. I don't want test to run along with unit tests.

Thank in advance!

1 Answers1

1

It seems that surefire plugin is hardcoded into Karate

I'm not sure where you got that impression, but no, the surefire plugin is not hardcoded into Karate.

Keep in mind that the simplest way to not run a JUnit test via surefire is to not use the *Test.java naming convention.

I think the solution for you is simple, whichever JUnit test is the "entry-point" for your Karate tests (the parallel runner is recommended) - just use the failsafe naming conventions.

And then, just include the failsafe plugin as per the examples and it should work. If you have trouble getting that to work (unlikely), then you should look at maven profiles.

EDIT: also see this comment: Is there a way to run Karate tests as an integration test suite against a pre-booted spring boot server?

Turns out that I cannot be done and it is a limitation of Maven, not Karate. Howto add another test source folder to Maven and compile it to a separate folder? - Here is my test project to prove it out: https://github.com/djangofan/spring-boot-hello - Thanks for leading me down what appears to have been the correct path to discover the limitation. Using Gradle would likely solve my issue but that is not an option on my project. If I use Karate for "separated integration tests", I need a separate mvn test module.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Hi Peter, thaks for your response. About "hardcoded" surefire plugin, in console output was another version than the one I pulled in my pom file but now it seems to be correct. About the real issue I fixed that with use of maven profiles. Thank again. – Adnan Sarajlic Jan 31 '18 at 10:16
  • @AdnanSarajlic great ! since you are new to Stack Overflow may I remind you to consider marking this answer as accepted. – Peter Thomas Jan 31 '18 at 10:19
  • 1
    I gave up trying to use Karate with failsafe. So now I just have tests in a separate module. I will have to figure something out to start/stop the test service , with it being a separate module. Will probably use a 2-phase Docker build file. – djangofan Dec 02 '19 at 04:11
  • 1
    The impression that surefire is kind of hard-coded comes from the fact, that even if the tests are started via maven-failsafe-plugin, the karate reports are still in /target/surefire-reports folder and not in failsafe-reports folder. – Mahatma_Fatal_Error Jul 24 '20 at 12:29
  • @Mahatma_Fatal_Error since it doesn't seem possible to get failsafe to work the right way with karate, it is likely to stay that way :) – Peter Thomas Jul 24 '20 at 12:33
  • @PeterThomas what do you mean by "does not seem possible"? Did you investigate it? If so, what blocked you? – djangofan Apr 05 '22 at 20:17
  • @djangofan I'm just quoting what you said in the second comment here, I haven't personally investigated this: https://stackoverflow.com/a/59084632/143475 – Peter Thomas Apr 06 '22 at 04:19