Skip to content

Conversation

@AZANIR
Copy link
Contributor

@AZANIR AZANIR commented Aug 24, 2025

  • Introduced a new Karate project with a Maven setup, including a pom.xml for dependencies.
  • Added a README.md detailing setup instructions, test scenarios, and integration steps.
  • Created feature files for testing the Swagger Petstore API with unique test IDs.
  • Implemented a test runner in Java to execute the Karate tests and generate JUnit XML reports.

- Introduced a new Karate project with a Maven setup, including a `pom.xml` for dependencies.
- Added a README.md detailing setup instructions, test scenarios, and integration steps.
- Created feature files for testing the Swagger Petstore API with unique test IDs.
- Implemented a test runner in Java to execute the Karate tests and generate JUnit XML reports.
Copy link
Contributor

@DavertMik DavertMik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To verbose overview


# 3. Create pom.xml with Karate dependencies
cat > pom.xml << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to do things like that?

Copy link
Contributor

@YevheniiVlasenko YevheniiVlasenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! There are a few things to improve!

Comment on lines +1 to +11
{
"permissions": {
"allow": [
"mcp__context7__resolve-library-id",
"mcp__context7__get-library-docs",
"Bash(mkdir:*)"
],
"deny": [],
"ask": []
}
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this does not belong here. It's local.

Comment on lines +176 to +191

```
karate-example/
├── pom.xml
├── README.md
└── src/
└── test/
├── java/
│ └── com/
│ └── testomat/
│ └── karate/
│ └── KarateTest.java
└── resources/
└── simple-api-test.feature
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this structure refers to the project the user creates in the first part of the README, then it's wrong. If it does not then as a user I can't see where I get this from.

Comment on lines +23 to +110
## 🚀 Setup Framework From Scratch (In a Nutshell)

### Quick Setup (5 minutes)

```bash
# 1. Create project directory
mkdir my-karate-project
cd my-karate-project

# 2. Create Maven directory structure
mkdir -p src/test/java/com/example/karate
mkdir -p src/test/resources

# 3. Create pom.xml with Karate dependencies
cat > pom.xml << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.example</groupId>
<artifactId>karate-project</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<karate.version>1.4.1</karate.version>
</properties>
<dependencies>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes><exclude>**/*.java</exclude></excludes>
</testResource>
</testResources>
</build>
</project>
EOF

# 4. Create test runner
cat > src/test/java/com/example/karate/TestRunner.java << 'EOF'
package com.example.karate;
import com.intuit.karate.Results;
import com.intuit.karate.Runner;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class TestRunner {
@Test
void testAll() {
Results results = Runner.path("classpath:")
.outputJunitXml(true)
.parallel(1);
assertTrue(results.getFailCount() == 0, results.getErrorMessages());
}
}
EOF

# 5. Create your first .feature file
cat > src/test/resources/sample-test.feature << 'EOF'
Feature: Sample API Test

Background:
* url 'https://petstore.swagger.io/v2'

Scenario Outline: Get pet - <testCase> @<testId>
Given path 'pet', <petId>
When method get
Then status <expectedStatus>

Examples:
| testCase | petId | expectedStatus | testId |
| existing | 1 | 200 | T1a2b3c4d |
| nonexistent | 999 | 404 | T5e6f7g8h |
EOF

# 6. Run your first test
mvn test
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it's a demo project that will not be or will be rarely updated, I would rather do this using Maven Archetype or, simpler, tell the user to clone the project with a ready-to-use structure. Both ways are more user-friendly and faster to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants