-
-
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
Feature request: make the KarateRuntimeOptions more flexible #520
Comments
@celcius112 can you please do me a favor, check out the 'cukexit' branch and try. the file loading has been completely re-written and as far as I can tell, it should support loading from a JAR file as well as the normal classpath. would appreciate your help here :) |
Oh yeah, saw your tweet on removing Cucumber :) |
So I tried the most recent version of you branch. There seems to be some issues at the moment:
Would you like a sample project in which we can easily reproduce these steps ? |
@celcius112 awesome, thanks ! So by "packaged" application, I assume you mean it is a JAR ? ideally I'd like the sample project to be included in the gradle project side-by-side with the karate-demo maven project: https://github.com/intuit/karate/blob/master/karate-demo/build.gradle I was resisting running this as part of CI until now but maybe we should. Hopefully even the creation of a JAR can be stuffed into the same project and we can run some tests to test all scenarios, would you be able to take a look at those ? By the way I'm right now working on getting the Intelli-J "right-click-and-run" working with the new Cucumber-free situation. As of now the IDE results (green bar etc) is broken, but do see if you spot any other issues ! |
@celcius112 nevermind, tried to work on all 3 issues and I think fixed. checked in a tiny jar file with some feature-files bundled, including relative-path call complications. here is the test: https://github.com/intuit/karate/blob/ef22ef37fb4e2511c4bb2e9a6eb182d2dd1b8daf/karate-junit4/src/test/java/com/intuit/karate/junit4/files/JarLoadingTest.java |
Thank you @ptrthomas !
Yep exactly :). So if we come back to my 3 points:
|
@celcius112 great ! I think it is time you submitted a PR. I've honestly reached the limit of my patience struggling with the weirdness of the |
@ptrthomas ok, hold my 🍺 (might take some time though) |
whoops, I should have read this thread... |
@celcius112 @jlee70 - I took another look at this and see the last commit above, I think I have been able to solve scanning within JAR files. we were missing adding anything in JAR files to classpath scanning earlier. would be great if you can build fro source and test. |
better unified file / path handling for files / jar zip file entries
Hello @ptrthomas, I have a feature file being called in my
|
@celcius112 sorry I won't be able to look at your issue unless you submit a full working example as per the instructions here: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue |
Hello @ptrthomas. I was following JarLoadingTest in the com.intuit.karate.junit4.files package. Feature feature = FeatureParser.parse(resource);
CallContext callContext = new CallContext(null, true);
//I ended up using Engine because I need FeatureResult to generate report.
FeatureResult result = Engine.executeFeatureSync(feature, (String)null, callContext);
File resultFile = Engine.saveResultHtml("target/surefire-reports/", result); In my prototype with above procedure, I am able to serve generated html in boot app and seems to work for my need and nice. It will be nice if I can specify file name in Engine.saveResultHtml call. So I can bind dynamic test run with report. Also, not sure what is a proper way to get karate-config.js in java. Is there some converter util method between karate-config.js and java map. config.js is not pure map and value I assume. thank you very much. |
@jlee70 I made the changes so you can override the filename for the report artifacts. I don't understand your question on karate-config.js |
oh thank you @ptrthomas. For karate-config.js, according to my debug tracing, karate-configuration gets loaded through public ScenarioContext(FeatureContext featureContext, CallContext call) {
...
if (call.parentContext == null && call.evalKarateConfig) {
// base config is only looked for in the classpath
try {
Script.callAndUpdateConfigAndAlsoVarsIfMapReturned(false, ScriptBindings.READ_KARATE_CONFIG_BASE, null, this);
} catch (Exception e) {
if (e instanceof KarateFileNotFoundException) {
logger.trace("skipping 'classpath:karate-base.js': {}", e.getMessage());
} else {
throw new RuntimeException("evaluation of 'classpath:karate-base.js' failed", e);
}
String configDir = System.getProperty(ScriptBindings.KARATE_CONFIG_DIR);
String configScript = ScriptBindings.readKarateConfigForEnv(true, configDir, null);
try {
Script.callAndUpdateConfigAndAlsoVarsIfMapReturned(false, configScript, null, this);
} catch (Exception e) {
if (e instanceof KarateFileNotFoundException) {
logger.warn("skipping bootstrap configuration: {}", e.getMessage());
} else {
throw new RuntimeException("evaluation of '" + ScriptBindings.KARATE_CONFIG_JS + "' failed", e);
}
}
//maybe third configuration loading here if callcontext has custom config file location.
//then load that custom config with specified file location?
... and whoops I did not read code completely... there is a way to specify configuration folder and loaded config from the folder... I will try that approach first before asking new feature. thanks |
0.9.0 released |
Hello Peter,
I have a Spring Boot application in which I launch my Karate tests at runtime, meaning that the cucumber features will be bundled in a jar (or a bootJar to be more precise). I'm using the Cucumber's parallel runner (
CucumberRunner
).Since Spring Boot manages by itself its jar, the
MultiLoader
used byKarateRuntimeOptions
will not be able to discover the features on the classpath, as described in this issue.I was able to use my own
ResourceLoader
, and everything works fine, but I had to extendKarateRuntimeOptions
and pretty much override everything and modify the class loader, which is not very lenient in case of any modification in the current API.Sorry if I don't have a very precise request, since I'm not sure what's the best way to resolve that, and for having a pretty farfetched use-case, but I can say for sure that on the long term it might be a good idea to make
KarateRuntimeOptions
a bit more flexible.If you want a demo project with my use-case and my solution, I'm more than willing to provide it.
Thank you very much
The text was updated successfully, but these errors were encountered: