zenwave360 / karate-ide Goto Github PK
View Code? Open in Web Editor NEWThe Best OpenSource IDE for KarateDSL.
Home Page: https://marketplace.visualstudio.com/items?itemName=KarateIDE.karate-ide
License: Other
The Best OpenSource IDE for KarateDSL.
Home Page: https://marketplace.visualstudio.com/items?itemName=KarateIDE.karate-ide
License: Other
Currently karate runtime and debugger runs as ShellExecution tasks with little control for output logs content.
Replacing ShellExecution with child_process.spwan and OutputChannels will allow to parse and extract logs for failing (or not) karate tests and click to scroll to relevant log information from Karate-IDE UI elements.
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?
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
After we have completed these and other features we may join forces again with original upstream project.
Hi,
I have:
Visual Studio Code
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
petstore.yaml
and of api.yaml
doesn't ring any bell.karate-1.4.0.jar
to karate.jar
has no effect.{
"karateIDE.karateCli.karateEnv": ""
}
Current Karate Debugger Startup process is slow and cumbersome:
target/karate-debug-port.txt
New workflow will be:
child_process.spawn
#5Hi @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.
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).
Hi,
I'd like to store my tests in a custom folder location in my Node.js project. Can I do this? If yes, how?
Thanks!
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.
There is nothing in the documentation that states how this should be defined. I get a failure for all the generators
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" <
When open the VS Code workspace with multi-roots, .feature files are not detected by Karate IDE and not code lens applied to .feature files
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.
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.