-
-
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
Path variable being concatenated #1990
Comments
@snow23man let me stop you right at the point when you keep referring to
anyway to try and get to a conclusion sooner, here is my best attempt to interpret what you are trying to do. feel free to build on the example below. the latest version of karate supports a call to a scenario in the same feature. you can cut and paste this into a new feature, and it will actually work (unlike your example): Feature:
Background:
* def baseUrl = 'https://httpbin.org/'
Scenario:
* def result = call read('@called')
* url baseUrl
* path 'anything'
* method get
@ignore @called
Scenario:
* url baseUrl
* path 'get'
* method get |
@ptrthomas if it's not intended or supported usage, how come it has been working fine this way for years. That being said, changing to declare a variable of baseUrl in the background of the main feature file and then set the path to that in the helper feature and again setting in the scenario right after the call to the helper feature has worked for both. So thanks for the help in the end, took a long road to get here |
I have no problem if you consider it a "bug" (that can be blamed on me if it makes people feel better) which is now fixed. anyway, glad to know you have a way forward |
Thanks for your suggestion @ptrthomas :-) It is an idea/suggestion, but i think it could be over usefull to externalize "ignored called" scenario inside a dedicated .feature file which could be called by all other .feature file is needed. As it works perfectly with Karate version <= 1.1.0. Anyway, i think i found a solution to cover this need, i could use "url" parameter only including the path inside instead of using "path" parameter. Like this at it seems to avoid the concatenaion issue with the "path" parameter: Instead of:
I do not know if it is correct but it seems to works. Regards, |
@kdefives I'm sorry I don't follow, your description is confusing. I'll pick one line out of your comment and respond to that if it helps.
that's simple, just use a variable like everybody else. I don't see the problem. |
I cannot use a variable, because each distinct call must generate a unique JWT token dynamically. I will try to explain what i do with a simple example, sorry in advance if it is not clear enough: Feature file A:
Feature file B:
Feature file JWT token generator (jwt-generator.feature):
If i follow your suggestion, i have to duplicate the content of jwt-generator.feature inside each of my *.feature to test. |
@kdefives still confused. but if you mean the JWT URL is different, you can pass arguments to call:
|
Yes but it is not avoiding the problem of concatenation using path parameter. Because if i am executing this code, then the http call did by the Scenario @called-to-generate-jwt will be [my_url_generator_jw]/anything/token' instead of [my_url_generator_jw]/token' We do not understand why the path parameter from Scenario of Feature file A is concatenated to the path of Scenario @called-to-generate-jwt The workaround i found below: Feature file A:
Feature file B:
Feature file JWT token generator (jwt-generator.feature):
Avoid using path parameter and concatenate manually using url parameter. |
@kdefives I mean that you should also not have that I'm sorry if you need more discussion, submit a proper way to replicate: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue |
@ptrthomas your solution is working too. 👍 ==> Update: The solution is finally not working. My implementation below: Feature file B:
Feature file JWT token generator (jwt-generator.feature):
Just to really understand what happened, the problem of concatenation of paths inside Scenario of jwt-generator.feature was due to the "Background" declared inside jwt-generator.feature (side effect)? |
@kdefives I need to check and it certainly can be a bug. it makes it easier if people follow the process, and right now I don't consider it a priority. I also wish that this feedback comes at the time we urge people to try RC releases (for months) if anyone can replicate this in a way that proves it is a bug, I can open an issue |
My test was wrong. Finally, using this suggested solution it is still not working. For peoples who faced the same issue, the workaround i found which is working is to use: instead of: Thanks for this discussion which helped me to found this workaround. |
@kdefives great. yes |
I understood the issue which @kdefives is facing becuase I also facing the same issue. It make senses to magically concatenated the |
@cheanwei open a new issue, follow this process and create the SIMPLEST example you possibly can: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue before that let me say that karate's design is that when you make a if you contribute a fix and it doesn't break any other tests, we can consider including it. |
@ptrthomas I am new to Karate. I just started to use Karate since version 1.2.0.RC1. In fact I like the design of Karate and agree to lose any url or path information when I make a call to another scenario. This works fine until I update Karate to version 1.2.0. Unfortunately, I don't have time to create the example repo which reproduce the issue now. The temporary solution for me now is to roll back the Karate version to 1.2.0.RC1. |
no worries. there are 3 people in this thread and I still haven't got any idea what the problem is. I'm not spending any more time on this |
tagging #2054 as I think it is relevant to this thread |
all: I'm willing to acknowledge that posted some thoughts here, do comment if you have a PoV: #2202 (comment) |
When you use a "helper feature file" and call it from your main feature file in a scenario, the "path" variable is being concatenated. Resetting doesn't change the result, neither does using a different variable than path in the scenario.
In version 1.1.0 you could essentially re-use the path variable without problems, however on version 1.2.0.RC6 there is this concatenation issue.
I've attached 2 basic features that reproduce the issue.
Inside the main feature the url and path get set. The helper feature file will read those and work no problem. However when the scenario from the main feature does it's call instead of being "https://api.publicapis.org/entries", since it gets concatenated it becomes "https://api.publicapis.org/entries.org/entries".
features.zip
.
The text was updated successfully, but these errors were encountered: