Skip to content
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] - Enable downstream consumers to plugin in DSL customizations #1909

Closed
krmahadevan opened this issue Feb 4, 2022 · 5 comments
Labels

Comments

@krmahadevan
Copy link

Currently Karate lets users plugin in customisations by letting users to add in their custom implementations (such as make a gRPC call or a DB call or a Unix ssh etc.,) via the Java.type() syntax.

For e.g., assuming that one has a need to do ssh operations for which one would like to use karate, then one needs to make use of

def SshClient = Java.type('com.foo.bar.SshClient')
def client = new SshClient(localhost,21)

This kind of takes away the readability of a feature file and requires that a person knows a bit more about programming to be able to understand what happens here and how to go about tracing the call.

If a user forgets to add comments for reach of these def statements, then the report gets polluted with all these code lines being shown up in the Karate reports instead of some english statements.

This issue tracks the following asks (I will be raising a PR for this as well shortly)

  • As a Karate user, I should be able to come up with my own DSL (similar to how we have keywords defined in com.intuit.karate.ScenarioActions)
  • I should be able to plugin my custom DSL into Karate and leverage everything else that Karate provides me.

Here's an example of what I am looking for

Feature: Greet Feature

  Scenario: Greet scenario
    * def name = 'Dragon Warrior'
    * greet name
@ptrthomas
Copy link
Member

@krmahadevan this has been discussed in detail in #398

you can choose to submit a PR after reading the whole thread to propose an implementation, but as of now I consider it unlikely that we support what you ask for

@krmahadevan
Copy link
Author

krmahadevan commented Feb 4, 2022

@ptrthomas - Would you be willing to atleast take a look at the PR because its not aimed at taking any of the cucumber route etc., but all its doing is just to facilitate a user to be able to plugin their own constructs, and Karate merely honours them.

If after looking at the PR, you still feel its not going to be taken, I am fine with it. I can always override the CLASSPATH locally (lock down on a Karate version in my test project) and still wire in this capability in my project and solve my problem statement.

Here's the PR: #1911

@ptrthomas
Copy link
Member

@krmahadevan I looked at the PR. it is clearly not the approach I want to take especially with the dependency on cucumber.api.java.en.When. there's also a Plugin interface I've been exploring, but not completed: https://github.com/karatelabs/karate/blob/v1.2.0.RC1/karate-core/src/main/java/com/intuit/karate/core/Plugin.java

thanks for the suggestions and feedback, right now I'm just extremely careful about extra keywords and it will open up questions and edge cases on life-cycle, reporting and debugging - and I personally think scripting via JS is the priority.

@krmahadevan
Copy link
Author

@ptrthomas - Sure. I just piggy backed on what was already there in ScenarioActions and hence the @When annotation reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants