Skip to content

Commit

Permalink
Release (#21)
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
  • Loading branch information
HardNorth authored Jan 16, 2024
1 parent 1e27f4e commit e220481
Show file tree
Hide file tree
Showing 64 changed files with 4,807 additions and 529 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright 2020 EPAM Systems
# Copyright 2022 EPAM Systems
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -17,16 +17,15 @@ on:
push:
branches:
- '*'
- '!master'
- '!main'
paths-ignore:
- README.md
- README_TEMPLATE.md
- CHANGELOG.md

pull_request:
branches:
- master
- develop
- main

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ hs_err_pid*
.gradle/
build/
test-output/
target/

# IntelliJ Idea files
.idea/
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## [Unreleased]
- Take items' startTime and endTime from Karate.
### Changed
- Refactored and implemented main ReportPortal agent features, by @HardNorth

## [1.0.6]
### Changed
Expand Down
177 changes: 177 additions & 0 deletions README_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# 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://slack.epmrpp.reportportal.io/badge.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: $LATEST_VERSION. 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>agent-java-karate</artifactId>
<version>$LATEST_VERSION</version>
<scope>test</scope>
</dependency>

<!-- build config omitted -->
</project>
```

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:$LATEST_VERSION'
}
```

## 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
43 changes: 43 additions & 0 deletions build-quality.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2024 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:4.8.0'
}
}

apply plugin: com.github.spotbugs.snom.SpotBugsPlugin

spotbugs {
toolVersion = '3.1.12'
effort = 'max'
reportLevel = 'high'
}

spotbugsMain {
sourceDirs = files(sourceSets.main.allSource.srcDirs)
classDirs = files(sourceSets.main.output)
auxClassPaths = files(sourceSets.main.compileClasspath)
reports {
html.enabled(true)
xml.enabled(false)
}
}
53 changes: 29 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2023 EPAM Systems
* Copyright 2024 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -15,47 +15,58 @@
*/

apply plugin: 'java-library'
apply plugin: 'maven-publish'

// Blocking issue for gradle version >=7.0:https://github.com/reportportal/gradle-scripts/issues/37
//apply from: "${project.scripts_url}/${project.scripts_branch}/release-commons.gradle"
//apply from: "${project.scripts_url}/${project.scripts_branch}/build-quality.gradle"
//apply from: "${project.scripts_url}/${project.scripts_branch}/signing.gradle"
apply from: 'build-quality.gradle'
apply from: "${project.scripts_url}/${project.scripts_branch}/release-commons.gradle"
apply from: "${project.scripts_url}/${project.scripts_branch}/signing.gradle"
apply from: "${project.scripts_url}/${project.scripts_branch}/jacoco.gradle"

project.ext.limits = [
'instruction': 70,
'branch' : 53,
'line' : 75,
'complexity' : 60,
'method' : 65,
'class' : 83
]

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
api "com.epam.reportportal:client-java:${project.reportportal_client_java_version}"
api "com.epam.reportportal:logger-java-logback:${project.reportportal_logback_version}"
api 'com.epam.reportportal:client-java:5.2.0'
api "com.intuit.karate:karate-core:${project.karate_version}"
implementation 'org.slf4j:slf4j-api:2.0.7'

testImplementation 'com.epam.reportportal:logger-java-logback:5.2.0'
testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.2'
testImplementation "org.junit.jupiter:junit-jupiter-api:${project.junit_version}"
testImplementation "org.junit.jupiter:junit-jupiter-engine:${project.junit_version}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${project.junit_version}"
testImplementation "org.mockito:mockito-core:${project.mockito_version}"
testImplementation "org.mockito:mockito-junit-jupiter:${project.mockito_version}"
}

tasks.withType(Test) {
jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED',
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
'--add-opens', 'java.base/java.util.concurrent=ALL-UNNAMED']
testImplementation 'org.hamcrest:hamcrest-core:2.2'
testImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
}

test {
outputs.upToDateWhen { return false }
maxParallelForks(5)
useJUnitPlatform()
doFirst {
def weaver = configurations.testRuntimeClasspath.find { it.name.contains("aspectjweaver") }
jvmArgs += "-javaagent:$weaver"
jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED',
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
'--add-opens', 'java.base/java.util.concurrent=ALL-UNNAMED']
}
environment "AGENT_NO_ANALYTICS", "1"
testLogging {
Expand All @@ -74,10 +85,4 @@ processResources {
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
build.dependsOn jacocoTestReport
11 changes: 5 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name=agent-java-karate
version=1.0.6
description=EPAM Report portal. Karate test framework [1.3.1, ) adapter
version=5.0.0-SNAPSHOT
description=EPAM ReportPortal. Karate test framework [1.3.1, ) adapter
gradle_version=8.2
reportportal_client_java_version=5.1.16
reportportal_logback_version=5.1.3
karate_version=[1.3.1, )
junit_version=5.10.0-M1
junit_version=5.10.1
mockito_version=5.4.0
scripts_url=https://raw.githubusercontent.com/reportportal/gradle-scripts
scripts_branch=master
scripts_branch=develop
excludeTests=
Loading

0 comments on commit e220481

Please sign in to comment.