-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Handle Karate tests in a BootJar #833
Conversation
And thank a lot for all these existing tests 😅 It makes me more confident in my changes |
@celcius112 this is good stuff and I have no problem merging this. but should I wait for the "full" solution ? |
@ptrthomas I don't mind waiting. This PR was done in order to have more insight (if needed) on the changes before moving on the next issues. Anyway we won't use these changes in production until Karate is released |
@celcius112 okay, let's wait - as you said, since all the existing tests pass we should be good, thanks for writing tests and do add more if needed |
@celcius112 just one thought - if we move the |
yeah I though about exploring this solution for simplifying the |
Hello @ptrthomas, For your interest, I will try in the near future to modify the |
Hello, so after some investigation here's half (or maybe 2/3) of the solution to launch Karate tests inside a jar packaged by Spring Boot.
Here are the important changes brought by this PR:
Runner
, thefeatureExecutor
will be initialized using aprivilegedThreadFactory()
in order to have access to the invoking thread'scontextClassLoader
. Spring Boot sets its ownClassLoader
in the thread's context, and thisClassLoader
is very useful in retrieving packaged feature files. EachExecutionContext
retrieves thecontextClassLoader
, which is then passed down to eachScenarioContext
.CallContext
. When resolving a scenario we cannot retrieve the Spring Boot's ClassLoader by usingThread.currentThread().getContextClassLoader()
because we are in a Thread managed by a ForkJoinPool (the executorscenarioExecutor
inRunner
).karate-http.properties
FileUtils
to create aResource
wrapping aURL
. ThisURL
is a good pointer to the packaged files.BootJarLoadingTest
uses the newly added jarkarate-bootjar-test.jar
to test the new modifications.I previously said "half of the solution" because at the moment
this
and relative path resolution mechanisms do not work, such ascall read('this:a.feature')
andcall read('../a.feature')
. Also, the Karate'sResource
class should probably be modified in order to be more generic in the resources it can handle (seeBootJarLoadingTest
to see the working solution we've been using since we started using Karate with Spring Boot). I'm currently working on a solution for that.