-
-
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
[discuss] improvements to mocks in the next version #1338
Comments
Pure javascript looks good too, I'm thinking to improve readability you'll need to add few more helper functions. e.g. an example
This is just an example, but allowing some kind of router-subrouter will help split the more advanced mocks. This is where well thought out helper methods would help avoid boiler-plate and the mocks maintainable. |
@michaelpro1 great, thanks for taking a look. I also would lean towards being more "opinionated" for e.g.
|
This seems OK for simple mocks (without wildcard/regex params), but for advanced usage maybe ServerContext can also lookout for
Are you planning on using the non-locking request processing as I see with ThreadLocals?
Cool let me know if you want me to add them once you are done |
here's where my PoV is that this is a "mock" ;) that said, I'll wait for the advanced use cases to become obvious. i the meantime feel free to provide examples of these advanced use cases. my hypothesis is that the way it is right now is sufficient to build a complete back-end (including HTML templating BTW) and yes, I'm going with ThreadLocal all the way |
I do find that mocks start off small but tend to grow larger as systems start interacting with more and more things. One example would be BenTen's Karate mocks, and another is more generic Test Harness that could encompass OAuth, Microservices and even some external APIs which may or may not have wildcard path parameters. Deferring all logic to the underlying JS allows your codebase to be minimal, as routing, code re-use etc. is handled by underlying JS/GraalJS Engine while still allowing for opinionated mock organization when main file is omitted. Templating and matching are definately the more powerful facets of Karate, though its unusual for REST API to render HTML out. They definitely come in handy with JSON request/responses though. |
@michaelpro1 noted. I think there is a need for regarding html - you can try run ServerRunner - navigate to |
Ahh you're using Thymeleaf for that, do you think it would make more sense to apply the HTML logic if either
Otherwise using Thymeleaf is excellent 👍 at this kind of thing, just have to make sure that its cache is cleared on file refresh if it's using any. |
@michaelpro1 I think you are still thinking REST, this is way more ambitious - intended to be "the web framework I always wanted". for e.g. this is not just Thymeleaf - but combined with GraalJS - more on this later but for now see what happens at runtime to |
Hi @ptrthomas and @michaelpro1, I had been using Karate Mock 0.9.5 for a while. And noticed there were big changes on scenario-matching algorithm from 0.9.5 to 0.9.6. In 0.9.6 calculating scores makes the mock scenario-matching rule more complex. And did not see any document to explain the scenario matching rule before diving into the change commits #1159. I like all of the mock improvement ideas and especially the bullet points 1, 5, 6, 7 listed at the beginning. And expect the mock improvement release coming soon. |
@hujunhaorobert thanks for the feedback, this helps. keep watching the twitter / linkedin feeds for updates, we'll announce when RC releases are ready |
@hujunhaorobert I've just brought the would be good if you can follow the development guide on the wiki and try things locally |
@ptrthomas Just noticed your message. Thanks for your effort on the mock server improvement. Yes, I will try that locally firstly and then give feedback to you. |
closing this thread, use #1373 for any more discussion |
also paging @michaelpro1 as this is related to #1159
lots to unpack here, so will start with bullet points - feel free to ask questions and I can elaborate
let me know your thoughts :) and @michaelpro1 feel free to weigh in with design suggestions based on your experience with the old mocks
The text was updated successfully, but these errors were encountered: