-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Issues calling .feature file and java code #544
Comments
thanks for the detailed example:
* def prevRequest = karate.prevRequest
* call read("showPrevRequestHeaders.feature") { prevRequest: '#(prevRequest)' }
* def resultOfMyVoidMethod = myClassInstance.myVoidMethod("hello")
* eval myClassInstance.myVoidMethod("foo") |
Thanks for the reply. Really 1+2 are related.
(3) the syntax confused me, IMHO it could be worth changing the WARN to an error of some sort. |
I'm going to disagree here based on experience. if you are doing something so complex, move it into Java or at least JS. I'm now dealing with a team that has so much in JS and "called" features that they are not able to debug and troubleshoot problems. so I'm inclined not to support this unless we get a PR or something. actually if you do a |
one more thing I really discourage calling features except in cases where you do a common "setup". |
I thought calling .feature files was the way to go What sort of PR would you be interested in? |
@connorsadlervelo you can pass a JSON in one line so your args are name-spaced. * def foo = { bar: 1, baz: 2, ban: 3 } any other questions ? |
I am not sure of the overall recommendation here Is the only other option to avoid this completely and call Java or Javascript? Thanks for the help so far! |
workaround for YOUR specific edge-case which is not recommended. IMO a very reasonable workaround - but you can choose to disagree. you can use a Java utility to do this "mimic json" you speak of if it is not already covered here: https://github.com/intuit/karate#the-karate-object |
BTW this is where I got the original recommendation from - see your answer on stack overflow. I know I could use another library to do the json logic, I'd rather use karate functions if possible. |
we are going in circles here. the problem is you want |
Not at all, I'd rather not pass it anywhere, that was itself a workaround. BTW the report "error on JSON serialization of args" issue - that problem occurred with another of our Java objects, not just the karate one. |
Already answered in my first comment in this thread. I have nothing more to add.
As per design. You already know normal JSON is fine. BTW Java |
Sigh, getting nowhere here. I give up. For people finding this thread in future EDIT by [peter] --> @ptrthomas | responses inline.
[peter] exactly as per design. each feature opens a new scope without which karate would break in all kinds of ways. in just one extra line you can save the value of
[peter] wow, that's such a cheap shot considering the amount of effort that has gone into the documentation. I'll leave it to readers to decide the merit of your accusation. and of course this is in a situation which we do not support (which is passing the
[peter] simple. for complex stuff which you seem to want to do (framework-y stuff like storing the previous values of request headers) please use Java for maintenance and debug-ability reasons. we recommend that re-usable features be used sparingly and only for "set-up" routines, but many teams break this rule without any problems.
[peter] I have NO idea what you are talking about. wild guess: when you are going to java, you shouldn't worry about JSON anymore because you will get the object as-is |
I'm keeping this open because there is a fix for passing |
Fair enough. |
@connorsadlervelo lol, didn't notice your sneaky ninja edit :) I've edited your comment with my responses to your conclusions. |
Peter, IMHO you are taking this far too personally. Editing my response has cluttered the conversation and made it difficult for me to reply. There were no "cheap shots" at all there. I was stating factually my observations and conclusions. Your documentation does state that we are not limited, but it appears there are limits there. Your own response on Stack Overflow originally led me down the .feature path. Do you think you should go back and edit that, if your advice has changed? |
Nope, if you make sweeping accusations it is my responsibility to provide my PoV. And I'm going to ignore the accusations you continue to make above for the sake of ending this discussion sooner. Again - let the readers decide, based on what they have seen here in the other issues and on Stack Overflow.
I do have to remind you here that it was you who made an edit to an old comment - so I never realized that you had injected a whole bunch of accusations for the world to read.
IMO that is a general question where feature re-use made sense, I could be wrong though :) |
"Accusations"? |
I'll make one last point as I lock this thread as an administrator. What really ticked me off here is the continued reference to The docs say no such thing. There is this statement though completely in the context of re-usable Java code:
Peace. |
Hi,
Couple of issues found while calling out to .feature files and also to Java code
Please see attached zip file for reproducible
3 scenarios are in cats-java.feature
You can run them using: CatsJavaRunner
(these files were cribbed from examples as you'll probably recognise)
Will paste in the cats-java.feature below to show the 3 scenarios in the ticket - please see zip for full code and dependencies.
Thanks,
Connor
The text was updated successfully, but these errors were encountered: