Skip to content

Commit 7f9ac6d

Browse files
authored
Merge pull request #112 from testomatio/Issue-103_Karate
Issue-103 Improve Karate Scenario Outline result handling and TestId …
2 parents 62709cc + 4a0758f commit 7f9ac6d

10 files changed

Lines changed: 26 additions & 36 deletions

File tree

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ and team collaboration features.
2222
| **Shared run** | Collaborative test execution sharing |||||
2323
| **Test runs grouping** | Organize and categorize test executions |||||
2424
| **Public sharable link** | Generate public URLs for test run results |||||
25-
| **Test code export** | Export test code from codebase to platform |||| |
25+
| **Test code export** | Export test code from codebase to platform |||| |
2626
| **Advanced error reporting** | Detailed test failure/skip descriptions |||||
27-
| **TestId import** | Import test IDs from testomat.io into the codebase |||| |
27+
| **TestId import** | Import test IDs from testomat.io into the codebase |||| |
2828
| **Test filter by ID** | Run tests filtered by IDs |||||
2929
| **Parametrized tests support** | Enhanced support for parameterized testing |||||
3030
| **Test artifacts support** | Screenshots, logs, and file attachments |||||
@@ -37,7 +37,6 @@ and team collaboration features.
3737
| What you need | Version | We tested with | Supported java version |
3838
|---------------|:-------:|:--------------:|:----------------------:|
3939
| **JUnit** | 5.x | 5.9.2 | Java 11+ |
40-
| **TestNG** | 7.x | 7.7.1 | Java 11+ |
4140
| **Cucumber** | 7.x | 7.14.0 | Java 11+ |
4241
| **Karate** | 1.x | 1.5.0 | Java 17+ |
4342

@@ -48,7 +47,7 @@ and team collaboration features.
4847
1. **Add the latest version** of the dependency to your POM.xml:
4948
[TestNG](https://central.sonatype.com/artifact/io.testomat/java-reporter-testng)
5049
[JUnit](https://central.sonatype.com/artifact/io.testomat/java-reporter-junit)
51-
[Cucumber](https://central.sonatype.com/artifact/io.testomat/java-reporter-cucumber)
50+
[Cucumber](https://central.sonatype.com/artifact/io.testomat/java-reporter-cucumber)
5251
[Karate](https://central.sonatype.com/artifact/io.testomat/java-reporter-karate)
5352

5453
2. **Get your API key** from [Testomat.io](https://app.testomat.io/) (starts with `tstmt_`)
@@ -255,37 +254,37 @@ Feature: User Authentication
255254
```
256255

257256
### For Karate
258-
257+
Test ID format: ```@T + 8 alphanumeric characters.```
259258
```gherkin
260259
Feature: Posts API
261260
262261
Background:
263262
* url 'https://jsonplaceholder.typicode.com'
264263
* def assertStatus = Java.type('helpers.AssertStatus')
265264
266-
@Title:Get_all_posts @TestId:Tpost0001 @Attachments:logs/karate.log
265+
@Title:Get_all_posts @Tpost0001 @Attachments:logs/karate.log
267266
Scenario: Get all posts
268267
Given path 'posts'
269268
When method get
270269
Then eval assertStatus.checkStatusCode(responseStatus, 200)
271270
And match response[0].id != null
272271
273-
@Title:Get_single_post @TestId:Tpost0002
272+
@Title:Get_single_post @Tpost0002
274273
Scenario: Get single post
275274
Given path 'posts', 1
276275
When method get
277276
Then eval assertStatus.checkStatusCode(responseStatus, 200)
278277
And match response.id == 1
279278
280-
@Title:Get_comments_for_post @TestId:Tpost0003
279+
@Title:Get_comments_for_post @Tpost0003
281280
Scenario: Get comments for post
282281
Given path 'posts', 1, 'comments'
283282
When method get
284283
Then eval assertStatus.checkStatusCode(responseStatus, 200)
285284
And match response[0].postId == 1
286285
287-
@Title:Validate_post_titles @TestId:Tpost0004
288-
Scenario Outline: Validate post titles <TestId>
286+
@Title:Validate_post_titles @Tpost0004
287+
Scenario Outline: Validate post titles
289288
Given path 'posts', <id>
290289
When method get
291290
Then eval assertStatus.checkStatusCode(responseStatus, 200)
@@ -297,7 +296,7 @@ Feature: Posts API
297296
| 2 |
298297
| 3 |
299298
300-
@Title:Create_post @TestId:Tpost0005
299+
@Title:Create_post @Tpost0005
301300
Scenario: Create post
302301
Given path 'posts'
303302
And request { title: 'foo', body: 'bar', userId: 1 }

java-reporter-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>io.testomat</groupId>
99
<artifactId>java-reporter-core</artifactId>
10-
<version>0.9.1</version>
10+
<version>0.9.2</version>
1111
<packaging>jar</packaging>
1212

1313
<name>Testomat.io Reporter Core</name>

java-reporter-core/src/main/java/io/testomat/core/constants/CommonConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.testomat.core.constants;
22

33
public class CommonConstants {
4-
public static final String REPORTER_VERSION = "0.9.1";
4+
public static final String REPORTER_VERSION = "0.9.2";
55

66
public static final String TESTS_STRING = "tests";
77
public static final String API_KEY_STRING = "api_key";

java-reporter-cucumber/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<dependency>
5252
<groupId>io.testomat</groupId>
5353
<artifactId>java-reporter-core</artifactId>
54-
<version>0.9.1</version>
54+
<version>0.9.2</version>
5555
</dependency>
5656
<dependency>
5757
<groupId>org.slf4j</groupId>

java-reporter-junit/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<dependency>
5252
<groupId>io.testomat</groupId>
5353
<artifactId>java-reporter-core</artifactId>
54-
<version>0.9.1</version>
54+
<version>0.9.2</version>
5555
</dependency>
5656
<dependency>
5757
<groupId>org.slf4j</groupId>

java-reporter-karate/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.testomat</groupId>
88
<artifactId>java-reporter-karate</artifactId>
9-
<version>0.2.3</version>
9+
<version>0.2.4</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Testomat.io Java Reporter Karate</name>
@@ -52,7 +52,7 @@
5252
<dependency>
5353
<groupId>io.testomat</groupId>
5454
<artifactId>java-reporter-core</artifactId>
55-
<version>0.9.1</version>
55+
<version>0.9.2</version>
5656
</dependency>
5757
<dependency>
5858
<groupId>io.karatelabs</groupId>

java-reporter-karate/src/main/java/io/testomat/karate/constructor/KarateTestResultConstructor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public TestResult constructTestRunResult(ScenarioRuntime sr) {
5757
.withTitle(testDataExtractor.extractTitle(sr))
5858
.withRid(testDataExtractor.getRid(sr))
5959
.withMessage(exceptionDetails.getMessage())
60-
.withStack(exceptionDetails.getStack());
60+
.withStack(exceptionDetails.getStack())
61+
.withOverwrite(false);
6162

6263
if (!steps.isEmpty()) {
6364
builder.withSteps(steps);

java-reporter-karate/src/main/java/io/testomat/karate/extractor/TestDataExtractor.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.util.Arrays;
1414
import java.util.Objects;
1515
import java.util.UUID;
16-
import java.util.stream.Stream;
1716
import org.slf4j.Logger;
1817
import org.slf4j.LoggerFactory;
1918

@@ -26,7 +25,6 @@ public class TestDataExtractor {
2625

2726
private static final Logger log = LoggerFactory.getLogger(TestDataExtractor.class);
2827
private static final String TEST_ID_REGEX = "T[a-z0-9]{8}";
29-
private static final String TEST_ID_PREFIX = "testid";
3028
private static final String TITLE_PREFIX = "title:";
3129
private static final String ATTACHMENTS_PREFIX = "attachments:";
3230

@@ -46,19 +44,18 @@ public ExceptionDetails extractExceptionDetails(ScenarioRuntime sr) {
4644
/**
4745
* Extracts a test identifier from scenario tags.
4846
* <p>
49-
* Searches for the first tag that starts with the configured {@code TEST_ID_PREFIX}
50-
* (case-insensitive), removes the prefix, and validates the remaining value.
47+
* Searches for the first tag that starts with the configured {@code TEST_ID_REGEX}
5148
*
5249
* @param sr the {@link ScenarioRuntime} of the executed Karate scenario
5350
* @return the extracted test identifier, or {@code null} if none is found
5451
*/
5552
public String extractTestId(ScenarioRuntime sr) {
56-
return findFirstValidTestId(sr.tags.getTags().stream()
53+
return sr.tags.getTags().stream()
5754
.filter(Objects::nonNull)
58-
.filter(tag -> tag.regionMatches(true, 0,
59-
TEST_ID_PREFIX, 0, TEST_ID_PREFIX.length()))
60-
.map(tag -> tag.substring(TEST_ID_PREFIX.length() + 1)));
61-
55+
.filter(id -> id.matches(TEST_ID_REGEX))
56+
.map(id -> "@" + id)
57+
.findFirst()
58+
.orElse(null);
6259
}
6360

6461
/**
@@ -161,13 +158,6 @@ public String getRid(ScenarioRuntime sr) {
161158
return UUID.nameUUIDFromBytes(raw.getBytes()).toString();
162159
}
163160

164-
private String findFirstValidTestId(Stream<String> ids) {
165-
return ids
166-
.filter(id -> id.matches(TEST_ID_REGEX))
167-
.findFirst()
168-
.orElse(null);
169-
}
170-
171161
private ExceptionDetails createExceptionDetails(Throwable throwable) {
172162
String message = throwable.getMessage();
173163
String stack = getStackTrace(throwable);

java-reporter-testng/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<dependency>
4848
<groupId>io.testomat</groupId>
4949
<artifactId>java-reporter-core</artifactId>
50-
<version>0.9.1</version>
50+
<version>0.9.2</version>
5151
</dependency>
5252
<dependency>
5353
<groupId>org.slf4j</groupId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.testomat</groupId>
88
<artifactId>java-reporter</artifactId>
9-
<version>0.2.0</version>
9+
<version>0.2.1</version>
1010
<packaging>pom</packaging>
1111

1212
<name>Testomat.io Java Reporter</name>

0 commit comments

Comments
 (0)