{"id":25776815,"url":"https://github.com/reportportal/agent-java-testNG","last_synced_at":"2025-02-27T06:06:57.122Z","repository":{"id":11453753,"uuid":"69727527","full_name":"reportportal/agent-java-testNG","owner":"reportportal","description":"TestNG listener","archived":false,"fork":false,"pushed_at":"2025-01-21T13:09:40.000Z","size":1196,"stargazers_count":55,"open_issues_count":3,"forks_count":20,"subscribers_count":25,"default_branch":"develop","last_synced_at":"2025-01-21T14:21:52.677Z","etag":null,"topics":["java","reportportal","testing","testng"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reportportal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-01T08:23:08.000Z","updated_at":"2025-01-21T13:09:44.000Z","dependencies_parsed_at":"2024-02-07T20:30:47.130Z","dependency_job_id":"b1b2b360-947a-472a-8c25-6eac82961154","html_url":"https://github.com/reportportal/agent-java-testNG","commit_stats":null,"previous_names":[],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reportportal%2Fagent-java-testNG","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reportportal%2Fagent-java-testNG/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reportportal%2Fagent-java-testNG/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reportportal%2Fagent-java-testNG/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reportportal","download_url":"https://codeload.github.com/reportportal/agent-java-testNG/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240987435,"owners_count":19889335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","reportportal","testing","testng"],"created_at":"2025-02-27T06:01:31.662Z","updated_at":"2025-02-27T06:06:57.108Z","avatar_url":"https://github.com/reportportal.png","language":"Java","funding_links":[],"categories":["测试"],"sub_categories":[],"readme":"# ReportPortal Listener for TestNG tests\nA TestNG reporter that uploads the results to a ReportPortal server.\n\n\u003e **DISCLAIMER**: We use Google Analytics for sending anonymous usage information such as agent's and client's names, and their versions\n\u003e after a successful launch start. This information might help us to improve both ReportPortal backend and client sides. It is used by the\n\u003e ReportPortal team only and is not supposed for sharing with 3rd parties.\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/agent-java-testng.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.epam.reportportal/agent-java-testng)\n[![CI Build](https://github.com/reportportal/agent-java-testNG/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/agent-java-testNG/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/reportportal/agent-java-testNG/branch/develop/graph/badge.svg?token=CshHrWt7sS)](https://codecov.io/gh/reportportal/agent-java-testNG)\n[![Join Slack chat!](https://img.shields.io/badge/slack-join-brightgreen.svg)](https://slack.epmrpp.reportportal.io/)\n[![stackoverflow](https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/reportportal)\n[![Build with Love](https://img.shields.io/badge/build%20with-❤%EF%B8%8F%E2%80%8D-lightgrey.svg)](http://reportportal.io?style=flat)\n\nThe latest version: 5.4.6. Please use `Maven Central` link above to get the agent.\n**For TestNG version [7.1.0](https://central.sonatype.com/artifact/org.testng/testng/7.1.0) and higher**\n\n## Overview: How to Add ReportPortal Logging to Your Project\n\nTo start using ReportPortal with TestNG framework please do the following steps:\n\n1. [Configuration](#configuration)\n    * Create/update the `reportportal.properties` configuration file\n    * Build system configuration\n    * Add Listener\n2. [Logging configuration](#logging)\n    * Loggers and their types\n3. [Running tests](#running-tests)\n    * Build system commands\n4. [Custom use examples](#customization)\n\n## Configuration\n### 'reportportal.properties' configuration file\n\nTo start using ReportPortal you need to create a file named `reportportal.properties` in your Java project in a source\nfolder `src/main/resources` or `src/test/resources` (depending on where your tests are located):\n\n**reportportal.properties**\n\n```\nrp.endpoint = http://localhost:8080\nrp.api.key = e0e541d8-b1cd-426a-ae18-b771173c545a\nrp.launch = TestNG Tests\nrp.project = default_personal\n```\n\n**Property description**\n\n* `rp.endpoint` - the URL for the ReportPortal server (actual link).\n* `rp.api.key` - an access token for ReportPortal which is used for user identification. It can be found on your report\n  portal user profile page.\n* `rp.project` - a project ID on which the agent will report test launches. Must be set to one of your assigned\n  projects.\n* `rp.launch` - a user-selected identifier of test launches.\n\n\nThe full list of supported properties is located here in client-java library documentation (a common library for all\nJava agents): https://github.com/reportportal/client-java\n\n## Build system configuration\n\n### Maven\n\nIf your project is Maven-based you need to add dependencies to `pom.xml` file:\n```xml\n\u003cproject\u003e\n  \u003c!-- project declaration omitted --\u003e\n  \n  \u003cdependency\u003e\n    \u003cgroupId\u003ecom.epam.reportportal\u003c/groupId\u003e\n    \u003cartifactId\u003eagent-java-testng\u003c/artifactId\u003e\n    \u003cversion\u003e5.4.6\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n  \u003c/dependency\u003e\n\n  \u003c!-- build config omitted --\u003e\n\u003c/project\u003e\n```\nYou are free to use you own version of TestNG, but not earlier than 7.1.0. If you leave just Agent dependency it will\nbe still OK, it will use transitive TestNG version.\n\n### Gradle\n\nFor Gradle-based projects please update dependencies section in `build.gradle` file:\n```groovy\ndependencies {\n    testImplementation 'com.epam.reportportal:agent-java-testng:5.4.6'\n}\n```\n\n## Listener configuration\nThere are many ways to configure a listener in TestNG, but the most elegant and recommended way is to use a\n`ServiceLoader` file. Here is how you can do that:\n\n1. Create folders **_/META-INF/services_** in **_resources_** folder (`src/main/resources` or `src/test/resources`)\n2. Put there a file named **_org.testng.ITestNGListener_**\n3. Put a default implementation reference as a single row into the file: **_com.epam.reportportal.testng.ReportPortalTestNGListener_**\n\nExample:\n__/META-INF/services/org.testng.ITestNGListener__\n```none\ncom.epam.reportportal.testng.ReportPortalTestNGListener\n```\n\nThat's it! You are all set.\n\n## Logging\n\nReportPortal provides its own logger implementations for major logging frameworks like *Log4j* and *Logback*. It also\nprovides additional formatting features for popular client and test libraries like: *Selenide*, *Apache HttpComponents*,\n*Rest Assured*, etc.\n\nHere is the list of supported loggers and setup documentation links.\n\n**Logging frameworks:**\n\n| **Library name**       | **Documentation link**                                      |\n|------------------------|-------------------------------------------------------------|\n| Log4j                  | https://github.com/reportportal/logger-java-log4j           |\n| Logback                | https://github.com/reportportal/logger-java-logback         |\n\n**HTTP clients:**\n\n| **Library name**       | **Documentation link**                                      |\n|------------------------|-------------------------------------------------------------|\n| OkHttp3                | https://github.com/reportportal/logger-java-okhttp3         |\n| Apache HttpComponents  | https://github.com/reportportal/logger-java-httpcomponents  |\n\n**Test frameworks:**\n\n| **Library name** | **Documentation link**                                     |\n|------------------|------------------------------------------------------------|\n| Selenide         | https://github.com/reportportal/logger-java-selenide       |\n| Rest Assured     | https://github.com/reportportal/logger-java-rest-assured   |\n\n## Running tests\n\nWe are set. To run tests we just need to execute corresponding command in our build system.\n\n#### Maven\n\n`mvn test` or `mvnw test` if you are using Maven wrapper\n\n#### Gradle\n\n`gradle test` or `gradlew test` if you are using Gradle wrapper\n\n## Customization\n\n### Code example How to overload params in run-time\n\nAs a sample you can use code for **Override UUID** in run-time\n```java\n\tpublic static class MyListener extends BaseTestNGListener {\n\t\tpublic MyListener() {\n\t\t\tsuper(new ParamOverrideTestNgService());\n\t\t}\n\t}\n\n\tpublic static class ParamOverrideTestNgService extends TestNGService {\n\t\tpublic ParamOverrideTestNgService() {\n\t\t\tsuper(getLaunchOverriddenProperties());\n\t\t}\n\n\t\tprivate static Supplier\u003cLaunch\u003e getLaunchOverriddenProperties() {\n\t\t\tListenerParameters parameters = new ListenerParameters(PropertiesLoader.load());\n\t\t\tparameters.setApiKey(\"my crazy uuid\");\n\t\t\tReportPortal reportPortal = ReportPortal.builder().withParameters(parameters).build();\n\t\t\tStartLaunchRQ rq = buildStartLaunch(reportPortal.getParameters());\n\t\t\treturn new Supplier\u003cLaunch\u003e() {\n\t\t\t\t@Override\n\t\t\t\tpublic Launch get() {\n\t\t\t\t\treturn reportPortal.newLaunch(rq);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tprivate static StartLaunchRQ buildStartLaunch(ListenerParameters parameters) {\n\t\t\tStartLaunchRQ rq = new StartLaunchRQ();\n\t\t\trq.setName(parameters.getLaunchName());\n\t\t\trq.setStartTime(Calendar.getInstance().getTime());\n\t\t\trq.setAttributes(parameters.getAttributes());\n\t\t\trq.setMode(parameters.getLaunchRunningMode());\n\t\t\tif (!Strings.isNullOrEmpty(parameters.getDescription())) {\n\t\t\t\trq.setDescription(parameters.getDescription());\n\t\t\t}\n\n\t\t\treturn rq;\n\t\t}\n\t}\n```\n\n### Example repository\n\nThere are two modules under Example project which represent agent usage with Lo4j and Logback loggers:\n* https://github.com/reportportal/examples-java/tree/master/example-testng-log4j\n* https://github.com/reportportal/examples-java/tree/master/example-testng-logback\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freportportal%2Fagent-java-testNG","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freportportal%2Fagent-java-testNG","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freportportal%2Fagent-java-testNG/lists"}