Coder Social home page Coder Social logo

zenwave360 / karate-ide Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 4.0 36.67 MB

The Best OpenSource IDE for KarateDSL.

Home Page: https://marketplace.visualstudio.com/items?itemName=KarateIDE.karate-ide

License: Other

TypeScript 67.36% Java 21.49% EJS 4.86% JavaScript 6.29%
karate-tests mock-server openapi testing vscode vscode-extension

karate-ide's People

Contributors

dependabot[bot] avatar ivangsa avatar kirkia avatar kirksl avatar mohitkrishna12 avatar ptrthomas avatar techmaster21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

karate-ide's Issues

Feature requuest

Is there a away to add test templates, I would like to add some basic security testing to make sure code handles stuff like no access token, invalid token ( expired, invalid aud, issuer) etc, is there any means to do this?

Track first iteration fork efforts

This project started as a fork from original karate-runner extension.

We would like to make this extension a one stop and our primary tool for:

a) Rest APIs manual testing and debug leveraging already existing karate scripts
b) Karate scripts development

adding it some functionality that we are missing from other tools like postman, chrome devtools or intellij...

Checklist

  • Karate.env switcher
  • Focus/Filter features/scenarios and test-data files using glob regexps and karate tags
  • EventLogs Server listening from events send by a karate RuntimeHook with karate runtime information that will feed:
  • Structured http logs viewer using a tree view (v1)
    • Click to open request/response payloads in empty json document
    • Tree view (v2) with scenarios calls hierarchy
    • Click to open feature line where http calls are made
    • JsonPath filter command for opened payload json documents
  • Excutions view:
    • Replay last execution
    • Play single scenario from last execution
    • Click to open scenario from executions tree
  • Explore a way to keep session variables between manual executions (like authentication sessions or response output)
  • Karate feature code generation from OpenAPI definition command
  • Refactor launch/debug auto-configuration: don't try to guess build system or depend on configured default terminal to work.

After we have completed these and other features we may join forces again with original upstream project.

image

[error] TypeError: Cannot read properties of undefined (reading 'paths')

Hi,

I have:

Visual Studio Code

  • Version: 1.78.2
  • Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435
  • Date: 2023-05-10T14:44:45.204Z (2 wks ago)
  • Electron: 22.5.2
  • Chromium: 108.0.5359.215
  • Node.js: 16.17.1
  • V8: 10.8.168.25-electron.0
  • OS: Darwin x64 21.6.0
  • Sandboxed: Yes

ZenWave Karate IDE v1.3.4
ZenWave KarateIDE Classpath Jar v1.4.0
Karate Jar: karate-1.4.0.jar

Procedure
In the explorer, I right click a yaml file, then I click Karate IDE Generate Karate Test

Results
While with the petstore.yaml, the plugin works, with a api.yaml file created by me I get the error message below:

2023-05-31 16:20:41.076 [error] TypeError: Cannot read properties of undefined (reading 'paths')
	at t.getOperationsFor (/Users/dcremonini/.vscode/extensions/karateide.karate-ide-1.3.4/dist/extension.js:2:257374)
	at /Users/dcremonini/.vscode/extensions/karateide.karate-ide-1.3.4/dist/extension.js:2:252610
	at Generator.next (<anonymous>)
	at a (/Users/dcremonini/.vscode/extensions/karateide.karate-ide-1.3.4/dist/extension.js:2:251678) karateIDE.generators.openapi.test {"value":"KarateIDE.karate-ide","c":"karateide.karate-ide"}

Additional information

  • There aren't any similar bugs.
  • A comparison of the structure of the petstore.yaml and of api.yaml doesn't ring any bell.
  • I reinstalled the plugins a few times.
  • I can't share the original file but I'm willing to work on it to nail down the problem.
  • If I rename karate-1.4.0.jar to karate.jar has no effect.
  • In .vscode/settings.json I have:
{
    "karateIDE.karateCli.karateEnv": ""
}

Replace Karate Debugger Startup process

Current Karate Debugger Startup process is slow and cumbersome:

  • Karate java debug server process is started as ShellExecution
  • Karate-Runner creates a file watcher and and progress dialog and waits for file target/karate-debug-port.txt
  • DebugServer is started on a random port and random port is writtern to file
  • Karate-Runner starts a debug session and connects to karate DebugServer port
  • Karate-Runner/DebugSession sends debuging information: feature and breakpoints
  • When debuged feature is finished karate DebugServer exits and is discarded

New workflow will be:

  • Start Karate DebugServer on a given port using a node child_process.spawn #5
  • Start DebugSession and connect to DebugServer (using a timeout that allows time for DebugServer to start)
  • Keep Karate DebugServer open so future DebugSessions connect to this already open DebugServer saving a few secconds on subsequent debuging sessions

Issue with Auto-Generated Karate Feature Files: Schema Validation and Field Generation

Hi @ivangsa ,
Auto-generated Karate feature files often include optional fields with fuzzy matching, despite being marked as required in the schema.

{
  "id": "##number",
  "name": "##string",
  "status": "##string"
}

This issue revolves around the utilization of the buildKarateSchema function found within the test-data-generator.ts file.

   const required = options.requiredProps && options.requiredProps.includes(options.name);
   const nullable = schema.nullable === true || (Array.isArray(schema.type) && schema.type.includes("'null'"));
   const isOptionalPrefix = !required || nullable ? '#' : '';

In the above code required is always false because in the function call options parameter is empty object '{}'. Please review this issue. Correct me if I'm mistaken. Additionally, could you confirm whether it's possible to implement max length, min length, and regex pattern validations based on the schema of the spec file during the generation process?. I'm also open to contributing to address this matter if such assistance is needed.

Improvements

Hi @ivangsa ,

I think it would be great if it is possible to pass 'args' as a parameter directly in call read('classpath:karate-auth.js') args instead of passing it as 'args.auth'. So that in 'karate-auth.js' file we can write our own authentication logic with the help of other args. Like passing wrong access token based on the status code to get 404 error.

* def authHeader = call read('classpath:karate-auth.js') args.auth
* def headers = karate.merge(args.headers || {}, authHeader || {})

(Code snippet taken from the auto generated file).

Clarifications

Hi @ivangsa ,
Each api in the open api spec has (200,400,401 etc) response status codes. Karate-ide generated features file has covered these in scenario outline. But when I run the feature I am getting 200 for all response scenarios and getting failed. Is there anyway to handle these scenarios automatically. Like passing invalid data in params/request body to get 400 error.

I have handle 401 scenario by checking the status code and passing wrong token in karate-auth.js file.

"Karate: Run" is not getting maven options at settings.json

When using a customised maven settings xml, the "Karate: Run" option at a feature file is not using it

settings.json

{
    "karateRunner.karateRunner.default": "_SyncRunner",
    "maven.executable.options": "--settings ~/.m2/settings-eci-nexus.xml",
    "java.configuration.updateBuildConfiguration": "interactive"
}

launch.json

{
    // Use IntelliSense para saber los atributos posibles.
    // Mantenga el puntero para ver las descripciones de los existentes atributos.
    // Para más información, visite: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "karate-ide",
            "name": "Karate IDE (debug)",
            "request": "launch"
        }
    ]
}

Run command:

> Executing task: mvn clean test -f "/Users/XXXXX/Codigo/YYYYYY/pom.xml" -Dtest=_SyncRunner "-Dkarate.options=/Users/XXXXXX/Codigo/YYYYYY/src/test/java/ZZZZZZZZ/get-zzzzzz.feature:27" <

Does not support general configuration for reading nested resource folders since relies on classpath

Using https://github.com/kirksl/karate-runner/ I am able to configure debugging for any gradle project using a combination of build.gradle task

task karateExecute(type: JavaExec) {
    classpath = sourceSets.test.runtimeClasspath
    main = System.properties.getProperty('mainClass')
}

and launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "type": "karate",
            "name": "Karate (debug): Gradle",
            "request": "launch",
            "feature": "${command:karateRunner.getDebugFile}",
            "karateOptions": "",
            "karateCli": "./gradlew compileTestJava -Si -b \"${command:karateRunner.getDebugBuildFile}\" karateExecute -DmainClass=com.intuit.karate.cli.Main --args=\"-d\" ${config:karateRunner.karateRunner.commandLineArgs}"
        }

    ]
}

Similar functionality doesn't seem to exist for this plugin. Consequence is that if a file is located at src/test/java/foo/foo.feature it won't be found since by design java classpaths are not recursive.
Given that almost all of my projects use sub-folders, this effectively makes the extension unusable for me since for any user to debug it they need to manually configure classpath to include each sub-folder in the project.

Similarly, needing to provide a path to karate.jar is doubly problematic since the classpath entries are all interpreted as relative to the current project and absolute paths / and home directory ~/ are not supported.

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory in hierarchy project

I am getting a NoClassDefFoundError: org/slf4j/LoggerFactory exception in a hierarchy project although class path seems to be well formed.
This is the error

Executing: java '-Dkarate.env=' '-Dvscode.port=62986' -cp '/Users/XXXXX/.vscode/extensions/karateide.karate-ide-0.9.5/resources/vscode.jar:src/test/java:src/test/resources:target/classes:target/test-classes:/Users/XXXXX/.m2/repository/com/intuit/karate/karate-core/1.1.0/karate-core-1.1.0.jar;/Users/XXXXX/.m2/repository/org/graalvm/js/js-scriptengine/21.2.0/js-scriptengine-21.2.0.jar;/Users/XXXXX/.m2/repository/org/graalvm/sdk/graal-sdk/21.2.0/graal-sdk-21.2.0.jar;/Users/XXXXX/.m2/repository/org/graalvm/js/js/21.2.0/js-21.2.0.jar;/Users/XXXXX/.m2/repository/org/graalvm/regex/regex/21.2.0/regex-21.2.0.jar;/Users/XXXXX/.m2/repository/org/graalvm/truffle/truffle-api/21.2.0/truffle-api-21.2.0.jar;/Users/XXXXX/.m2/repository/com/ibm/icu/icu4j/69.1/icu4j-69.1.jar;/Users/XXXXX/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar;/Users/XXXXX/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar;/Users/XXXXX/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar;/Users/XXXXX/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.25/jcl-over-slf4j-1.7.25.jar;/Users/XXXXX/.m2/repository/com/jayway/jsonpath/json-path/2.6.0/json-path-2.6.0.jar;/Users/XXXXX/.m2/repository/net/minidev/json-smart/2.4.7/json-smart-2.4.7.jar;/Users/XXXXX/.m2/repository/net/minidev/accessors-smart/2.4.7/accessors-smart-2.4.7.jar;/Users/XXXXX/.m2/repository/org/ow2/asm/asm/9.1/asm-9.1.jar;/Users/XXXXX/.m2/repository/info/cukes/cucumber-java/1.2.5/cucumber-java-1.2.5.jar;/Users/XXXXX/.m2/repository/info/cukes/cucumber-core/1.2.5/cucumber-core-1.2.5.jar;/Users/XXXXX/.m2/repository/org/yaml/snakeyaml/1.29/snakeyaml-1.29.jar;/Users/XXXXX/.m2/repository/de/siegmar/fastcsv/2.0.0/fastcsv-2.0.0.jar;/Users/XXXXX/.m2/repository/info/picocli/picocli/4.6.1/picocli-4.6.1.jar' vscode.KarateTestProcess --backup-reportdir=false -H vscode.VSCodeHook  'src/test/java/entityData/entity/getEntity/get-entity.feature:27'

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
	at vscode.KarateTestProcess.<clinit>(KarateTestProcess.java:21)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
        NOTE: If you're seeing this message your "karateIDE.karateCli.classpath" setting is probably misconfigured.
        Please refer to the documentation for more information https://github.com/ivangsa/karate-ide#karate-classpath
        And run the "Configure Karate-IDE karate classpath" command for assistance (View > Command Palette or Ctrl+Shift+P).
        You can also consider installing "KarateIDE Classpath Jar" extension so you don't need to download karate.jar
        and stay up to date with the latest and greatest Karate release (coming soon).
                    
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 1 more

The project has no direct karate dependency, which are got from a parent project

This is parent's pom.xml, which includes karate-junit4 and karate-junit5 with karate 1.1.0 and karate-apache 0.9.4 (there's no karate-apache 1.1.0 yet ... https://repo1.maven.org/maven2/com/intuit/karate/karate-apache/ ) I also had to add a dependencyManagement section in order to handle conflicts

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>XXXXXXX</groupId>
    <artifactId>XXXXXX</artifactId>
    <version>1.0.0</version>
  </parent>

  <groupId>YYYYYYYYYY</groupId>
  <artifactId>YYYYYYYYY</artifactId>
  <version>1.4.1-SNAPSHOT</version>
  <packaging>pom</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <maven.compiler.version>3.6.0</maven.compiler.version>
    <maven.jar-plugin.version>3.1.2</maven.jar-plugin.version>
    <karate.version>1.1.0</karate.version>
    <gatling.plugin.version>2.2.4</gatling.plugin.version>
    <maven.surefire.version>3.0.0-M3</maven.surefire.version>
    <!-- ZZZZZZZ-versions -->
    <ZZZZZZZZZZ..version>1.2.4-SNAPSHOT</ZZZZZZZ.version>
    <ZZZZZZZZZZZ..version>1.9.3-SNAPSHOT</ZZZZZZZZZZZ.version>
    <jacoco.version>0.8.4</jacoco.version>
  </properties>

  <dependencies>


    <dependency>
      <groupId>com.intuit.karate</groupId>
      <artifactId>karate-junit4</artifactId>
      <version>${karate.version}</version>
    </dependency>

    <dependency>
      <groupId>com.intuit.karate</groupId>
      <artifactId>karate-junit5</artifactId>
      <version>${karate.version}</version>
    </dependency>

    <dependency>
      <groupId>com.intuit.karate</groupId>
      <artifactId>karate-apache</artifactId>
      <version>0.9.4</version>
    </dependency>

    <dependency>
      <groupId>net.masterthought</groupId>
      <artifactId>cucumber-reporting</artifactId>
      <version>3.8.0</version>
    </dependency>

    <dependency>
      <groupId>com.googlecode.json-simple</groupId>
      <artifactId>json-simple</artifactId>
      <version>1.1.1</version>
    </dependency>

  </dependencies>

  <build>

    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven.compiler.version}</version>
        <configuration>
          <encoding>UTF-8</encoding>
          <source>${java.version}</source>
          <target>${java.version}</target>
          <compilerArgument>-Werror</compilerArgument>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins>
    
  </build>

  <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.1</version>
        </dependency>
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-core</artifactId>
            <version>1.1.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>

</project>

These are the dependencies for both projects as shown by VS Code

Captura de pantalla 2021-11-29 a las 10 05 32

When using VS Code Configure Karate-IDE karate classpath from Command Palette and selecting M2_REPO option, in the parent project I got this new setting

 "karateIDE.karateCli.classpath": "src/test/java:src/test/resources:target/classes:target/test-classes:${m2.repo}/com/intuit/karate/karate-core/1.1.0/karate-core-1.1.0.jar;${m2.repo}/org/graalvm/js/js-scriptengine/21.2.0/js-scriptengine-21.2.0.jar;${m2.repo}/org/graalvm/sdk/graal-sdk/21.2.0/graal-sdk-21.2.0.jar;${m2.repo}/org/graalvm/js/js/21.2.0/js-21.2.0.jar;${m2.repo}/org/graalvm/regex/regex/21.2.0/regex-21.2.0.jar;${m2.repo}/org/graalvm/truffle/truffle-api/21.2.0/truffle-api-21.2.0.jar;${m2.repo}/com/ibm/icu/icu4j/69.1/icu4j-69.1.jar;${m2.repo}/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar;${m2.repo}/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar;${m2.repo}/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar;${m2.repo}/org/slf4j/jcl-over-slf4j/1.7.25/jcl-over-slf4j-1.7.25.jar;${m2.repo}/com/jayway/jsonpath/json-path/2.6.0/json-path-2.6.0.jar;${m2.repo}/net/minidev/json-smart/2.4.7/json-smart-2.4.7.jar;${m2.repo}/net/minidev/accessors-smart/2.4.7/accessors-smart-2.4.7.jar;${m2.repo}/org/ow2/asm/asm/9.1/asm-9.1.jar;${m2.repo}/info/cukes/cucumber-java/1.2.5/cucumber-java-1.2.5.jar;${m2.repo}/info/cukes/cucumber-core/1.2.5/cucumber-core-1.2.5.jar;${m2.repo}/org/yaml/snakeyaml/1.29/snakeyaml-1.29.jar;${m2.repo}/de/siegmar/fastcsv/2.0.0/fastcsv-2.0.0.jar;${m2.repo}/info/picocli/picocli/4.6.1/picocli-4.6.1.jar",

but when I use the same option in my project, there is no new karateIDE.karateCli.classpath option at settings.json. In any case, the classpath is generated as I pasted the run test command logs in the beginning of this issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.