Skip to content

Commit

Permalink
Release (#25)
Browse files Browse the repository at this point in the history
* Update CI build workflow

* Update build scripts

* Add the first integration test

* Dependency update

* The first Code Reference test, ReportPortal format apply, ignore target folder

* Do not output Cucumber to avoid failures in CI

* Revert last change

* A try to fix tests

* Add code reference for simple scenarios

* Add code reference for Examples scenarios

* Format fixes

* Code reference generation: sort by example key to unify code reference

* Add Test Case ID

* Attribute handling

* Fix tests

* System attributes reporting add

* Refactor item start method

* Add more tests

* Add scenario parameters reporting

* Update property format

* Add parameter handling for steps

* Add parameter log message verification

* Table parameters handling

* Background steps handling

* Test fixes

* Fix typing

* Background logic update

* Another background test

* Fix Table test

* Fix Table test

* Fix description

* Add another test

* Add Launch description test

* Small fix

* Small fix

* Add test

* Add junit-jupiter-params dependency

* Description and item name tests and fixes

* Fix test

* Refactoring

* Add parameter description to examples

* Add examples description tests

* Refactoring

* Add test

* Add test

* Fix test

* Update step logging

* Add test

* Add another test

* Add ReportPortal runtime hook publisher

* Refactoring, move common code to util class

* Fix parameter reporting

* Fix javadocs

* ReportPortalHook: WIP

* ReportPortalHook: WIP

* ReportPortalHook: WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* Add timing test and javadocs

* Add feature parameters tests

* Bump version

* Client version update

* Client version update

* Fix version number

* Update copyrights

* Update copyrights

* Code format apply

* Add README_TEMPLATE.md file

* Update README_TEMPLATE.md file

* Update release branch

* Update release.yml

* Update release.yml

* Update README.md

* Update README.md

* Update CHANGELOG.md

* Dependency versions update

* Actions versions update

* Karate version update

* Slack link update

* Add more tests

* Fixes issue #23 - scenarios outside features in parallel execution

---------

Co-authored-by: Reingold Shekhtel <13565058+raikbitters@users.noreply.github.com>
  • Loading branch information
HardNorth and raikbitters committed Mar 4, 2024
1 parent 3421fea commit 3d324c5
Show file tree
Hide file tree
Showing 11 changed files with 428 additions and 142 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
Expand All @@ -45,4 +45,6 @@ jobs:
run: ./gradlew build

- name: Codecov upload
run: bash <(curl -s https://codecov.io/bash)
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
24 changes: 17 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ env:
CHANGE_LOG_FILE: CHANGELOG.md
CHANGE_LOG_TMP_FILE: CHANGELOG_updated.md
REPOSITORY_URL: 'https://maven.pkg.github.com/'
README_FILE: README.md
README_TEMPLATE_FILE: README_TEMPLATE.md
README_VERSION_PLACEHOLDER: $LATEST_VERSION

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Generate versions
uses: HardNorth/github-version-generate@v1
Expand All @@ -46,7 +49,7 @@ jobs:
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }}

- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
Expand All @@ -66,6 +69,13 @@ jobs:
-PgithubUserName=${{ github.actor }} -PgithubToken=${{ secrets.GITHUB_TOKEN }} \
-PgpgPassphrase=${{ secrets.GPG_PASSPHRASE }} -PgpgPrivateKey="${{ secrets.GPG_PRIVATE_KEY }}"
- name: Update README.md
id: readmeUpdate
run: |
sed 's/${{ env.README_VERSION_PLACEHOLDER }}/${{ env.RELEASE_VERSION }}/g' ${{ env.README_TEMPLATE_FILE }} > ${{ env.README_FILE }}
git add ${{ env.README_FILE }}
git commit -m "Readme update"
- name: Update CHANGELOG.md
id: changelogUpdate
run: |
Expand Down Expand Up @@ -96,17 +106,17 @@ jobs:
body: ${{ steps.readChangelogEntry.outputs.changes }}

- name: Checkout develop branch
if: ${{github.ref}} == 'master'
uses: actions/checkout@v3
if: ${{github.ref}} == 'main'
uses: actions/checkout@v4
with:
ref: 'develop'
fetch-depth: 0

- name: Merge release branch into develop
id: mergeIntoDevelop
if: ${{github.ref}} == 'master'
if: ${{github.ref}} == 'main'
run: |
git merge -m 'Merge master branch into develop after a release' origin/master
git merge -m 'Merge main branch into develop after a release' origin/main
git status | (! grep -Fq 'both modified:') || git status | grep -F 'both modified:' \
| { echo -e 'Unable to merge master into develop, merge conflicts:'; (! grep -Eo '[^ ]+$') }
| { echo -e 'Unable to merge main into develop, merge conflicts:'; (! grep -Eo '[^ ]+$') }
git push origin develop
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Changelog

## [Unreleased]
### Changed
- Karate dependency marked as `compileOnly` to force users specify their own version of Karate, by @HardNorth
- Client version updated on [5.2.5](https://github.com/reportportal/client-java/releases/tag/5.2.5), by @HardNorth
### Fixed
- Issue [#23](https://github.com/reportportal/agent-java-karate/issues/23) scenarios outside features in parallel execution, by @HardNorth

## [5.0.0]
### Added
- Basic Agent functionality, by @vrymar
### Changed
- Refactored and implemented main ReportPortal agent features, by @HardNorth

Expand Down
289 changes: 172 additions & 117 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,122 +1,177 @@
# agent-java-karate

- [Description](#description)
- [Agent Configuration](#agent-configuration)
- [Properties File Configuration](#properties-file-configuration)
- [Execution](#execution)


## Description
ReportPortal Java agent for Karate testing tool.

## Agent Configuration
Until the agent-java-karate project is published to Maven repository,
the following configuration can be used:

* Add jitpack repository to get agent project from GitHub:
* Maven pom.xml
```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
```

* Gradle build.gradle
```groovy
repositories {
maven { url 'https://jitpack.io' }
}
```

* Add dependency for the agent project:
* Maven pom.xml
```xml
<dependency>
<groupId>com.github.vrymar</groupId>
<artifactId>agent-java-karate</artifactId>
<version>Tag_or_Version</version>
</dependency>
```

* Gradle build.gradle
```groovy
implementation 'com.github.vrymar:agent-java-karate:Tag_or_Version'
```


* Add reportportal `client-java` dependency:
* Maven pom.xml
```xml
# ReportPortal runtime Hook for Karate tests

Karate reporters which uploads the results to a ReportPortal server.

> **DISCLAIMER**: We use Google Analytics for sending anonymous usage information such as agent's and client's names, and their versions
> after a successful launch start. This information might help us to improve both ReportPortal backend and client sides. It is used by the
> ReportPortal team only and is not supposed for sharing with 3rd parties.
[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/agent-java-karate.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.epam.reportportal/agent-java-karate)
[![CI Build](https://github.com/reportportal/agent-java-karate/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/agent-java-karate/actions/workflows/ci.yml)
[![codecov](https://codecov.io/github/reportportal/agent-java-karate/graph/badge.svg?token=wJr9F6hZln)](https://codecov.io/github/reportportal/agent-java-karate)
[![Join Slack chat!](https://img.shields.io/badge/slack-join-brightgreen.svg)](https://slack.epmrpp.reportportal.io/)
[![stackoverflow](https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/reportportal)
[![Build with Love](https://img.shields.io/badge/build%20with-❤%EF%B8%8F%E2%80%8D-lightgrey.svg)](http://reportportal.io?style=flat)

The latest version: 5.0.0. Please use `Maven Central` link above to get the agent.

## Overview: How to Add ReportPortal Logging to Your Project

To start using ReportPortal with Karate framework please do the following steps:

1. [Configuration](#configuration)
* Create/update the `reportportal.properties` configuration file
* Build system configuration
* Add Listener
* Runtime
* Post-running
2. [Logging configuration](#logging)
* Loggers and their types
3. [Running tests](#running-tests)
* Build system commands

## Configuration

### 'reportportal.properties' configuration file

As the first step you need to create a file named `reportportal.properties` in your Java project in a source
folder `src/main/resources` or `src/test/resources` (depending on where your tests are located):

**reportportal.properties**

```
rp.endpoint = http://localhost:8080
rp.api.key = test_YIvQraKKSquDZqrA6JLCWCX5qwmMZBk_7tTm_fkN44AHCi18Ze0RtYqxWNYKxk5p
rp.launch = Karate Tests
rp.project = default_personal
```

**Property description**

* `rp.endpoint` - the URL for the ReportPortal server (actual link).
* `rp.api.key` - an access token for ReportPortal which is used for user identification. It can be found on your report
portal user profile page.
* `rp.project` - a project ID on which the agent will report test launches. Must be set to one of your assigned
projects.
* `rp.launch` - a user-selected identifier of test launches.

The full list of supported properties is located here in client-java library documentation (a common library for all
Java agents): https://github.com/reportportal/client-java

## Build system configuration

### Maven

If your project is Maven-based you need to add dependencies to `pom.xml` file:

```xml

<project>
<!-- project declaration omitted -->

<dependency>
<groupId>com.epam.reportportal</groupId>
<artifactId>client-java</artifactId>
<version>Tag_or_Version</version>
<groupId>com.epam.reportportal</groupId>
<artifactId>agent-java-karate</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
```
* Gradle build.gradle
```groovy
implementation 'com.epam.reportportal:client-java:Tag_or_Version'
```


**Note**: When the agent is approved by ReportPortal,
the agent repository can be taken from `reportportal`. E.g.:
* Maven pom.xml
```xml
<dependency>
<groupId>com.github.reportportal</groupId>
<artifactId>agent-java-karate</artifactId>
<version>Tag_or_Version</version>
</dependency>
```

* Gradle build.gradle
```groovy
implementation 'com.github.reportportal:agent-java-karate:Tag_or_Version'
```

## Properties File Configuration
* Create `reportportal.properties` file in `src\main\resources` directory.
* Add the following parameters:

<!-- build config omitted -->
</project>
```
rp.endpoint = <REPORTPORTAL_URL_ADDRESS>
rp.uuid = <REPORTPORTAL_PERSONAL_UUID>
rp.launch = <REPORTPORTAL_LAUNCH_NAME>
rp.project = <REPORTPORTAL_PROJECT_NAME>

OPTIONAL PARAMETERS
rp.reporting.async=true
rp.reporting.callback=true
rp.enable=true
rp.description=My awesome launch
rp.attributes=key:value;value
rp.rerun=true
rp.rerun.of=ae586912-841c-48de-9391-50720c35dd5a
rp.convertimage=true
rp.mode=DEFAULT
rp.skipped.issue=true
rp.batch.size.logs=20
rp.keystore.resource=<PATH_TO_YOUR_KEYSTORE>
rp.keystore.password=<PASSWORD_OF_YOUR_KEYSTORE>

You are free to use you own version of Karate, but not earlier than 1.0.0. If you leave just Agent dependency it will
be still OK, it will use transitive Karate version.

### Gradle

For Gradle-based projects please update dependencies section in `build.gradle` file:

```groovy
dependencies {
testImplementation 'com.epam.reportportal:agent-java-karate:5.0.0'
}
```

## Execution
To publish test results to ReportPortal, the test project should run by `KarateReportPortalRunner` instead of Karate runner.
E.g.:
```java
class scenarioRunnerTest {
@Test
void testParallel() {
KarateReportPortalRunner
.path("classpath:examples")
.outputCucumberJson(true)
.tags("~@ignore")
.parallel(1);
}
}
```
## Listener configuration

### Runtime

Runtime publisher uploads Karate tests on ReportPortal during the test execution, providing real-time monitoring capabilities. To publish
test results in this case, the test project should use by `ReportPortalHook` class, an instance of which you should pass to Karate runner.
E.G.:

```java
import com.epam.reportportal.karate.ReportPortalHook;
import com.intuit.karate.Runner;

class ScenarioRunnerTest {
@Test
void testParallel() {
return Runner
.path("classpath:examples")
.hook(new ReportPortalHook())
.outputCucumberJson(true)
.tags("~@ignore")
.parallel(1);
}
}
```

### Post-running

Post-running publisher uploads Karate tests on ReportPortal after the test execution. It uses Karate result object to get data about tests.
It might be useful if your tests make heavy load both on ReportPortal server or on the running node. To publish test results in this case,
the test project should run by `KarateReportPortalRunner` instead of Karate runner.
E.G.:

```java
import com.epam.reportportal.karate.KarateReportPortalRunner;

class ScenarioRunnerTest {
@Test
void testParallel() {
KarateReportPortalRunner
.path("classpath:examples")
.outputCucumberJson(true)
.tags("~@ignore")
.parallel(1);
}
}
```

## Logging

Karate uses `slf4j` as Logging library, so you are free to choose any Logging Framework.

ReportPortal provides its own logger implementations for major logging frameworks like *Log4j* and *Logback*. It also
provides additional formatting features for popular client and test libraries like: *Selenide*, *Apache HttpComponents*,
*Rest Assured*, etc.

Here is the list of supported loggers and setup documentation links.

**Logging frameworks:**

| **Library name** | **Documentation link** |
|------------------|-----------------------------------------------------|
| Log4j | https://github.com/reportportal/logger-java-log4j |
| Logback | https://github.com/reportportal/logger-java-logback |

**HTTP clients:**

| **Library name** | **Documentation link** |
|-----------------------|------------------------------------------------------------|
| OkHttp3 | https://github.com/reportportal/logger-java-okhttp3 |
| Apache HttpComponents | https://github.com/reportportal/logger-java-httpcomponents |

## Running tests

We are set. To run tests we just need to execute corresponding command in our build system.

#### Maven

`mvn test` or `mvnw test` if you are using Maven wrapper

#### Gradle

`gradle test` or `gradlew test` if you are using Gradle wrapper
Loading

0 comments on commit 3d324c5

Please sign in to comment.