Giter Site home page Giter Site logo

agent-java-junit's Introduction

Report Portal agent for JUnit 4

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 CI Build codecov Join Slack chat! stackoverflow Build with Love

Overview: How to Add ReportPortal Logging to Your JUnit Java Project

Report Portal supports JUnit 4 tests. The integration is built on top of JUnit Foundation framework by Scott Babcock.

  1. Configuration: Create/update the reportportal.properties configuration file
  2. Logback Framework: For the Logback framework:
    a. Create/update the logback.xml file
    b. Add ReportPortal / Logback dependencies to your project POM
  3. Log4J Framework: For the Log4J framework:
    a. Add ReportPortal / Log4J dependencies to your project POM
  4. Support for Parameterized Tests: Reporting of test parameters
  5. Images and Files: Logging images and files
  6. Step by step instruction: Report Portal and JUnit4 integration example

Configuration

Create/update the reportportal.properties configuration file:

Create or update a file named reportportal.properties in your Java project in source folder src/main/resources:

reportportal.properties

rp.endpoint = http://localhost:8080
rp.uuid = e0e541d8-b1cd-426a-ae18-b771173c545a
rp.launch = default_JUNIT_AGENT
rp.project = default_personal
  • The value of the rp.endpoint property is the URL for the report portal server(actual link).
  • The value of the rp.uuid property can be found on your report portal user profile page.
  • The value of the rp.project property must be set to one of your assigned projects.
  • The value of the rp.launch property is a user-selected identifier for the source of the report output (i.e. - the Java project)

Logback Framework

Create/update the logback.xml file:

In your project, create or update a file named logback.xml in the src/main/resources folder, adding the ReportPortal elements:

logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 
    <!-- Send debug messages to System.out -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!-- By default, encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{5} - %thread - %msg%n</pattern>
        </encoder>
    </appender>
 
    <appender name="RP" class="com.epam.reportportal.logback.appender.ReportPortalAppender">
        <encoder>
            <!--Best practice: don't put time and logging level to the final message. Appender do this for you-->
            <pattern>[%t] - %msg%n</pattern>
        </encoder>
    </appender>
 
    <!--'additivity' flag is important! Without it logback will double-log log messages-->
    <logger name="binary_data_logger" level="TRACE" additivity="false">
        <appender-ref ref="RP"/>
    </logger>
 
    <!-- By default, the level of the root level is set to DEBUG -->
    <root level="DEBUG">
        <appender-ref ref="RP"/>
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>

Add ReportPortal / Logback dependencies to your project POM:

pom.xml

<project ...>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>  	
  </properties>

  <dependencies>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.3.12</version>
    </dependency>
    <dependency>
      <groupId>com.epam.reportportal</groupId>
      <artifactId>agent-java-junit</artifactId>
      <version>5.2.3</version>
    </dependency>
    <dependency>
      <groupId>com.epam.reportportal</groupId>
      <artifactId>logger-java-logback</artifactId>
      <version>5.2.2</version>
    </dependency>
  </dependencies>
 
  <build>
    <pluginManagement>
      <plugins>
        <!-- Add this if you plan to import into Eclipse -->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <versionRange>[1.0.0,)</versionRange>
                    <goals>
                      <goal>properties</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <execute />
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <!-- This provides the path to the Java agent -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.1.1</version>
        <executions>
          <execution>
            <id>getClasspathFilenames</id>
            <goals>
              <goal>properties</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.0</version>
        <configuration>
          <argLine>-javaagent:${com.nordstrom.tools:junit-foundation:jar}</argLine>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Log4J Framework

Add ReportPortal / Log4J dependencies to your project POM:

pom.xml

<project ...>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>  	
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <version>2.17.2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <version>2.17.1</version>
    </dependency>
    <dependency>
      <groupId>com.epam.reportportal</groupId>
      <artifactId>agent-java-junit</artifactId>
      <version>5.2.3</version>
    </dependency>
    <dependency>
      <groupId>com.epam.reportportal</groupId>
      <artifactId>logger-java-log4j</artifactId>
      <version>5.2.2</version>
    </dependency>
  </dependencies>
 
  <build>
    <pluginManagement>
      <plugins>
        <!-- Add this if you plan to import into Eclipse -->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <versionRange>[1.0.0,)</versionRange>
                    <goals>
                      <goal>properties</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <execute />
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <!-- This provides the path to the Java agent -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.1.1</version>
        <executions>
          <execution>
            <id>getClasspathFilenames</id>
            <goals>
              <goal>properties</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.0</version>
        <configuration>
          <argLine>-javaagent:${com.nordstrom.tools:junit-foundation:jar}</argLine>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Gradle Configuration

apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8

description = 'ReportPortal JUnit 4 example'

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    compile 'com.epam.reportportal:logger-java-log4j:5.2.2'
    compile 'com.epam.reportportal:agent-java-junit:5.2.3'
}

test {
//  debug true
    jvmArgs "-javaagent:${classpath.find { it.name.contains('junit-foundation') }}"
    // not required, but definitely useful
    testLogging.showStandardStreams = true
}

Support for Parameterized Tests

The implementation of this Report Portal agent is built on test event notifications generated by JUnit Foundation. In addition to single-pass tests, this library provides support for parameterized tests. Here's a basic example:

Parameterized test class

package com.nordstrom.example;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static com.nordstrom.automation.junit.ArtifactParams.param;

import java.util.Map;
import java.util.Optional;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import com.nordstrom.automation.junit.ArtifactParams;
import com.nordstrom.automation.junit.AtomIdentity;


import com.nordstrom.automation.junit.ArtifactParams;
import com.nordstrom.automation.junit.AtomIdentity;

@RunWith(Parameterized.class)
public class ParameterizedTest implements ArtifactParams {
    
    @Rule
    public final AtomIdentity identity = new AtomIdentity(this);
    
    private String input;
    
    public ParameterizedTest(String input) {
        this.input = input;
    }
    
    @Parameters
    public static Object[] data() {
        return new Object[] { "first test", "second test" };
    }
    
    @Override
    public Description getDescription() {
        return identity.getDescription();
    }
    
    @Override
    public Optional<Map<String, Object>> getParameters() {
        return ArtifactParams.mapOf(param("input", input));
    }
    
    @Test
    public void parameterized() {
        System.out.println("invoking: " + getDescription().getMethodName());
        Optional<Map<String, Object>> params = identity.getParameters();
        assertTrue(params.isPresent());
        assertTrue(params.get().containsKey("input"));
        assertEquals(input, params.get().get("input"));
    }
}

When sending reports for tests in parameterized classes like this, the JUnit agent for Report Portal includes a record of the parameters that the tests were operating on. Below is an example of test item details for the parameterized() test, showing the value of the input parameter this test ran with.

test item details with parameter

Images and Files

http://reportportal.io/docs/Logging-Integration%3Elog-message-format

In addition to text log messages, ReportPortal has the ability to record images and file contents. The link above documents the formats supported by the report portal test listener for representing these artifacts.

ReportPortal integration with JUnit 4

This manual will walk you through the steps for integration of Report Portal with JUnit4 based project

First, make sure you have installed Report Portal, the installation steps could be found here

We’ll assume that Report Portal is installed and running on http://localhost:8080

Step 1 - Create new project (Maven)

If you want to integrate Report Portal with existing project, go to step 2

1.1 Start new maven project

Start new maven project

1.2 Enter GroupId and ArtifactId

Entering groupId and artifactId

1.3 Enter project name

Entering project name

Step 2 - Configure pom.xml

2.1 Add following dependencies:

Report Portal agent implementation for JUnit 4

<dependency>
    <groupId>com.epam.reportportal</groupId>
    <artifactId>agent-java-junit</artifactId>
    <version>5.2.3</version>
    <scope>test</scope>
</dependency>

Note that agent-java-junit brings in JUnit and the JUnit Foundation library as transitive dependencies, so these don't need to be declared explicitly in your project.

Latest version of the agent, could be found here

2.2 Add Report Portal dedicated logger wrapper

If you prefer using Logback logging library, add following dependencies:

ReportPortal logback logger dependency

<dependency>
    <groupId>com.epam.reportportal</groupId>
    <artifactId>logger-java-logback</artifactId>
    <version>5.2.2</version>
</dependency>

Up to date version could be found here

The logback itself

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.3.12</version>
</dependency>

If you prefer using Log4j logging library, add following dependencies:

ReportPortal log4j logger dependency

<dependency>
    <groupId>com.epam.reportportal</groupId>
    <artifactId>logger-java-log4j</artifactId>
    <version>5.2.2</version>
</dependency>

Up to date version could be found here

The log4j itself

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.17.2</version>
</dependency>

<dependency>
     <groupId>org.apache.logging.log4j</groupId>
     <artifactId>log4j-core</artifactId>
     <version>2.17.2</version>
</dependency>

Step 3 - Add the test with logging

3.1 Add simple test method

Create a test class MyTests in the test directory and add JUnit 4 test method there

package com.mycompany.tests;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;

public class MyTests {

    private static final Logger LOGGER = LogManager.getLogger(MyTests.class);
    
    @Test
    public void testMySimpleTest() {
        LOGGER.info("Hello from my simple test");
    }
}
3.2 Add log4j2.xml file to resources folder

Example:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration packages="com.epam.ta.reportportal.log4j.appender" status="WARN">
    <Appenders>
        <Console name="ConsoleAppender" target="SYSTEM_OUT">
            <PatternLayout
                    pattern="%d [%t] %-5level %logger{36} - %msg%n%throwable"/>
        </Console>
        <ReportPortalLog4j2Appender name="ReportPortalAppender">
            <PatternLayout
                    pattern="%d [%t] %-5level %logger{36} - %msg%n%throwable"/>
        </ReportPortalLog4j2Appender>
    </Appenders>
    <Loggers>
        <Root level="DEBUG">
            <AppenderRef ref="ConsoleAppender"/>
            <AppenderRef ref="ReportPortalAppender"/>
        </Root>
    </Loggers>
</Configuration>

It's needed to add ReportPortalAppender into this (as shown in the example)

By this moment, your project tree should look somewhat like the this:

Project structure

Step 4 - Configuring ReportPortal

4.1 Open ReportPortal UI

Go to http:$IP_ADDRESS_OF_REPORT_PORTAL:8080 (by default it is http://localhost:8080)

Login as Admin user and create the project (more details here and here)

RP. Add Project

RP. Add Project 2

4.2 Add users to your project:

Go to Administrative -> My Test Project -> Members -> Add user

Example link http://localhost:8080/ui/#administrate/project-details/my_test_project/members

RP. Add user

Step 5 - Link ReportPortal with your tests

Step 5.1 - Add reportportal.properties

After you have created new user in your project, you can get reportportal.properties file example from the user Profile page

To do that, login as created user and go to User icon in header -> Profile

There, in Configuration Examples section, you can find the example of reportportal.properties file for that user

RP. User profile

Returning back to the code. In your project, create file named reportportal.properties in resources folder and copy&paste the contents form the user profile page

Example:

reportportal.properties

rp.endpoint = http://localhost:8080
rp.uuid = d50810f1-ace9-44fc-b1ba-a0077fb3cc44
rp.launch = jack_TEST_EXAMPLE
rp.project = my_test_project
rp.enable = true

More details on reportportal.properties file could be found here

Step 5.2 - Make Report Portal agent invoked by the tests

Current Report Portal JUnit 4 Agent implementation uses "junit-foundation" library to intercept test steps and make possible to generate test-reports.

More about "junit-foundation" could be found here

So we need to inject the "junit-foundation' library into our running tests. There are multiple ways for doing that

  • method 1 - via Maven Surefire/Failsafe plugin (maven only)
  • method 2 - via IDE Run configurations
  • method 3 - via Gradle (gradle only)
Common Step - add service reference to your test resources

JUnit Foundation uses Java's Service Location mechanism to pick JUnit listeners. That also means you can specify multiple custom listeners and have them all reporting your test launch. To specify Report Portal Agent service reference create META-INF/services/com.nordstrom.automation.junit.JUnitWatcher file (note the directory path) in your resources directory. E.G. in src/test/resources. With the following content:

com.epam.reportportal.junit.ReportPortalListener

Prior to agent version 5.1 there was no need in this step, because the service was specified inside our package. But that caused troubles for those users who used their own customized agents based on our implementation. So to allow everyone to customize the agent service location was removed from our code.

Method 1 - using Maven Surefire/Failsafe plugin (maven only)

Add the build section and Maven Surefire plugin with the following configuration section to pom.xml

   <build>
      <pluginManagement>
         <plugins>
            <!-- This part is only needed for Eclipse IDE users-->
            <plugin>
               <groupId>org.eclipse.m2e</groupId>
               <artifactId>lifecycle-mapping</artifactId>
               <version>1.0.0</version>
               <configuration>
                  <lifecycleMappingMetadata>
                     <pluginExecutions>
                        <pluginExecution>
                           <pluginExecutionFilter>
                              <groupId>org.apache.maven.plugins</groupId>
                              <artifactId>maven-dependency-plugin</artifactId>
                              <versionRange>[1.0.0,)</versionRange>
                              <goals>
                                 <goal>properties</goal>
                              </goals>
                           </pluginExecutionFilter>
                           <action>
                              <execute/>
                           </action>
                        </pluginExecution>
                     </pluginExecutions>
                  </lifecycleMappingMetadata>
               </configuration>
            </plugin>
         </plugins>
      </pluginManagement>
      <plugins>
         <!-- This plugin provides the path to the Java agent (used in surefire argLine part) -->
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.1.1</version>
            <executions>
               <execution>
                  <id>getClasspathFilenames</id>
                  <goals>
                     <goal>properties</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
               <argLine>-javaagent:${com.nordstrom.tools:junit-foundation:jar}</argLine>
            </configuration>
         </plugin>
      </plugins>
   </build>

Please pay attention on Eclipse users block, you can remove it if you're not using Eclipse

Note - your IDE might get confused by the argLine value (in maven-surefire-plugin configuration section) and mark it as error. This is okay and argLine will still work, so you can set your IDE to ignore this error

IntelliJ IDEA suppress example

Note - in some cases the maven-dependency-plugin might also be marked red, since maven might be failing to download the dependency for it
in this case - add a maven dependency plugin dependency explicitly, like this:

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>3.1.1</version>
    <type>maven-plugin</type>
</dependency>

After maven imported new dependency, you can remove this dependency block

Full pom.xml file example

pom.xml

<?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.myCompany</groupId>
   <artifactId>myProject</artifactId>
   <version>1.0-SNAPSHOT</version>

   <dependencies>
      <dependency>
         <groupId>com.epam.reportportal</groupId>
         <artifactId>agent-java-junit</artifactId>
         <version>5.2.3</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>com.epam.reportportal</groupId>
         <artifactId>logger-java-log4j</artifactId>
         <version>5.2.2</version>
      </dependency>

      <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-api</artifactId>
         <version>2.17.2</version>
      </dependency>

      <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-core</artifactId>
         <version>2.17.2</version>
      </dependency>
   </dependencies>

   <build>
      <pluginManagement>
         <plugins>
            <!-- This part is only needed for Eclipse IDE users-->
            <plugin>
               <groupId>org.eclipse.m2e</groupId>
               <artifactId>lifecycle-mapping</artifactId>
               <version>1.0.0</version>
               <configuration>
                  <lifecycleMappingMetadata>
                     <pluginExecutions>
                        <pluginExecution>
                           <pluginExecutionFilter>
                              <groupId>org.apache.maven.plugins</groupId>
                              <artifactId>maven-dependency-plugin</artifactId>
                              <versionRange>[1.0.0,)</versionRange>
                              <goals>
                                 <goal>properties</goal>
                              </goals>
                           </pluginExecutionFilter>
                           <action>
                              <execute/>
                           </action>
                        </pluginExecution>
                     </pluginExecutions>
                  </lifecycleMappingMetadata>
               </configuration>
            </plugin>
         </plugins>
      </pluginManagement>
      <plugins>
         <!-- This plugin provides the path to the Java agent (used in surefire argLine part) -->
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.1.1</version>
            <executions>
               <execution>
                  <id>getClasspathFilenames</id>
                  <goals>
                     <goal>properties</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
               <!--suppress UnresolvedMavenProperty -->
               <argLine>-javaagent:${com.nordstrom.tools:junit-foundation:jar}</argLine>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

Now the Report Portal agent is linked to your tests and when you run the tests with maven (e.g. mvn clean test) the results should be sent Report Portal

Important note. With this approach, only the tests executed using maven will be sent to Report Portal and local runs will not trigger the Report Portal agent and therefore the test-report won't be generated
To have test results from local runs to be sent to Report Portal, follow the steps below

Method 2 - using IDE Run configurations

Another way to link local test runs with Report Portal is to add javaagent via Run Configurations of the IDE.

Example for IntelliJ IDEA

In Intellij IDEA go to Run -> Edit Configurations -> click on "+" sign -> select JUnit

IntelliJ IDEA add JUnit Run Configuration with javaagent

Enter the name of the run, select classes and/or methods to be run in this configuration and add the following line into VM Options field:

-javaagent:"path/to/junit-foundation.jar"

You can put the jar directly in the project tree or use the one, that Maven downloaded from "Method 1"

On MAC OS system the path to maven downloaded junit-foundation.jar would have the following format:

/Users/<user_name>/.m2/repository/com/nordstrom/tools/junit-foundation/12.5.3/junit-foundation-12.5.3.jar

When you are done adding local run configuration, simply go to Run -> Run '<test_run_name>' and that test run results will be sent to Report Portal

Method 3 - using Gradle test task (Gradle only)

Assuming that you have the default test task in your gradle.build file, you need to add jvmArgs part and junitFoundation variable from artifacts using following code:

test {
    jvmArgs "-javaagent:${classpath.find { it.name.contains('junit-foundation') }}"
    // your test task
}

And the full build.gradle file example:

apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    compile 'com.epam.reportportal:logger-java-log4j:5.2.2'
    compile 'com.epam.reportportal:agent-java-junit:5.2.3'
    compile 'org.apache.logging.log4j:log4j-api:2.17.2'
    compile 'org.apache.logging.log4j:log4j-core:2.17.2'
}

test {
    jvmArgs "-javaagent:${classpath.find { it.name.contains('junit-foundation') }}"
    testLogging.showStandardStreams = true
}

Step 6 - Observing test run report

After you linked the Report Portal JUnit 4 agent using one of the approaches described above, and ran your tests, you should be able to see the results in your ReportPortal instance
To do that, login to ReportPortal, and go to Left Panel -> Launches
You should see the launch there, with the name equal to the value of rp.launch from your reportportal.properties file

Example:

RP. Launches

You can also see the test classes and individual test results by clicking on the launch name and going deeper

RP. Test Results

Step 7 - Reporting parameterized test results to ReportPortal

ReportPortal JUnit 4 agent supports presenting parameterized test results, again using the junit-foundation agent

Here is an example of simple parameterized test and the code required to have test results sent to ReportPortal:

package com.mycompany.tests;

import com.nordstrom.automation.junit.ArtifactParams;
import com.nordstrom.automation.junit.AtomIdentity;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.Map;
import java.util.Optional;

@RunWith(Parameterized.class)
public class MyParameterizedTests implements ArtifactParams {

    private static final Logger LOGGER = LogManager.getLogger(MyParameterizedTests.class);

    @Rule
    public final AtomIdentity identity = new AtomIdentity(this);

    private String input;

    public MyParameterizedTests(String input) {
        this.input = input;
    }

    @Parameters
    public static Object[] data() {
        return new Object[] { "param1", "param2" };
    }

    @Test
    public void simpleParameterizedTest() {
        LOGGER.info("running test: " + getDescription().getMethodName() + ", parameter: " + input);
    }

    @Override
    public Description getDescription() {
        return identity.getDescription();
    }

    @Override
    public Optional<Map<String, Object>> getParameters() {
        return ArtifactParams.mapOf(ArtifactParams.param("input", input));
    }

}

AtomIdentity and ArtifactParams are classes from junit-foundation that should be used to link parameterized test with ReportPortal

In this example we have 2 items in the Object array returned by data() method, this means that the test simpleParameterizedTest will be executed twice with different parameters

After running this test class, the results in Report Portal should look somewhat like this:

Two invocations of parameterized test

Two invocation of test

Individual test result

Two invocation of test

Copyright Notice

Licensed under the Apache 2.0 license (see the LICENSE.md file).

agent-java-junit's People

Contributors

akoltochihin avatar augustasv avatar avarabyeu avatar dzmitrykavalets avatar filland avatar hardnorth avatar justalexone avatar pbortnik avatar sbabcoc avatar scorpibear avatar utdacc avatar yumfriez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agent-java-junit's Issues

Items doesn't finish in RP by reason of NPE in method stopOverAll()

Junit agent built from master branch

Stacktrace:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project rider-srv: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test failed: There was an error in the forked process [ERROR] org.apache.maven.surefire.testset.TestSetFailedException: java.lang.NullPointerException; nested exception is java.lang.NullPointerException: null [ERROR] java.lang.NullPointerException [ERROR] at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:210) [ERROR] at com.google.common.collect.Collections2$TransformedCollection.<init>(Collections2.java:256) [ERROR] at com.google.common.collect.Collections2.transform(Collections2.java:247) [ERROR] at com.epam.reportportal.junit.ParallelRunningHandler.stopOverAll(ParallelRunningHandler.java:386) [ERROR] at com.epam.reportportal.junit.ParallelRunningHandler.stopLaunch(ParallelRunningHandler.java:108) [ERROR] at com.epam.reportportal.junit.ReportPortalListener.testRunFinished(ReportPortalListener.java:99) [ERROR] at org.junit.runner.notification.SynchronizedRunListener.testRunFinished(SynchronizedRunListener.java:42) [ERROR] at org.junit.runner.notification.RunNotifier$2.notifyListener(RunNotifier.java:103) [ERROR] at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72) [ERROR] at org.junit.runner.notification.RunNotifier.fireTestRunFinished(RunNotifier.java:100) [ERROR] at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:127) [ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) [ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) [ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

Execution crashes when test class is marked as @Ignore

RP is able to successfully skip tests(methods) annotated with @ignore however classes with same annotations causes NullPointerException:

[ERROR] org.apache.maven.surefire.testset.TestSetFailedException: java.lang.NullPointerException
[ERROR] at org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures(JUnit4RunListener.java:209)
[ERROR] at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:169)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
[ERROR] Caused by: java.lang.NullPointerException
[ERROR] at com.epam.reportportal.junit.ParallelRunningHandler.buildStartTestItemRq(ParallelRunningHandler.java:307)
[ERROR] at com.epam.reportportal.junit.ParallelRunningHandler.handleTestSkip(ParallelRunningHandler.java:190)
[ERROR] at com.epam.reportportal.junit.ReportPortalListener.testIgnored(ReportPortalListener.java:97)
[ERROR] at com.nordstrom.automation.junit.RunAnnouncer.testIgnored(RunAnnouncer.java:92)
[ERROR] at org.junit.runner.notification.SynchronizedRunListener.testIgnored(SynchronizedRunListener.java:77)
[ERROR] at org.junit.runner.notification.RunNotifier$6.notifyListener(RunNotifier.java:174)
[ERROR] at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72)
[ERROR] at org.junit.runner.notification.RunNotifier.fireTestIgnored(RunNotifier.java:171)
[ERROR] at org.junit.internal.builders.IgnoredClassRunner.run(IgnoredClassRunner.java:16)
[ERROR] at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)
[ERROR] at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)
[ERROR] at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
[ERROR] at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
[ERROR] ... 3 more

Logs in RP UI are not displayed when using @Before annotations in the test

Hi guys,

I faced with an issue that no logs or assertion are available in ReportPortl UI if test class contains @before or @after annotation. Test launch and passed and failed test are displayed, but they are empty. With @BeforeClass and @afterclass logs and assertions are displayed ReportPortal UI.
It is possible to reproduce using DummyTest of this project by adding some failed assertions and logs in test methods.

[v5] Test result ignores JUnit rules

I'm using RP 5.3.3 and agent-java-junit v4 5.0-RC
I have a case where I'm using TestRule and the test is reported as a fail, although it passes

Retry rule class:

public class Retry implements TestRule {

    private static final Logger logger = LogManager.getLogger(Retry.class);

    private int retryCount;

    public Retry(int retryCount) {
        this.retryCount = retryCount;
    }

    public Statement apply(Statement base, Description description) {
        return statement(base, description);
    }

    private Statement statement(final Statement base, final Description description) {
        return new Statement() {
            @Override
            public void evaluate() throws Throwable {
                Throwable caughtThrowable = null;

                // implement retry logic here
                for (int i = 0; i < retryCount; i++) {
                    try {
                        base.evaluate();
                        return;
                    } catch (Throwable t) {
                        caughtThrowable = t;
                        logger.warn(description.getDisplayName() + ": run " + (i+1) + " failed");
                    }
                }
                logger.error(description.getDisplayName() + ": giving up after " + retryCount + " failures");
                throw caughtThrowable;
            }
        };
    }
}

In my test class, I have the implementation:

    @Rule
    public TestRule retry = new Retry(3);

When there is an exception in one of the tests once, the RP reports that the test is failed although it passed in the second time

Cannot include report portal in android repo because of `com.epam.reportportal:httpclient-repacked:1.0.2`

I tried to include this project in an android repo with
testImplementation ('com.epam.reportportal:agent-java-junit:2.7.2')
And I am getting this error
image

Things I tried so far

  1. Added a repository: maven { url 'http://dl.bintray.com/epam/reportportal' }
  2. Changed repository to jcenter { url 'http://dl.bintray.com/epam/reportportal' }
  3. Also tried to exclude the repacked module by
testImplementation ('com.epam.reportportal:agent-java-junit:2.7.2') {
  exclude group: 'com.epam.reportportal', module: 'httpclient-repacked'
 }

But this gives a compile error

Can't send logs to ReportPortal because com.epam.reportportal.service.LoggingContext.init is not called

Not sure if this is the right place for the issue since it could be fixed in a few repos.

agent-java-junit does not set the logging context

The log4j2 appender gets invoked

https://github.com/reportportal/logger-java-log4j/blob/master/src/main/java/com/epam/ta/reportportal/log4j/appender/ReportPortalLog4j2Appender.java#L90

But then ignores the log because the logging context was never set.

https://github.com/reportportal/client-java/blob/master/src/main/java/com/epam/reportportal/service/ReportPortal.java#L146

I can send logs when using testNG because then logging context is set from

https://github.com/reportportal/agent-java-testNG/blob/master/src/main/java/com/epam/reportportal/testng/TestNGService.java#L109

then

https://github.com/reportportal/client-java/blob/bb58bb0f5ee1913fa7ba5f724d372eb1db9360fd/src/main/java/com/epam/reportportal/service/LaunchImpl.java#L197

I know almost nothing about this code base, but I'm curious as to why the testNG agent uses Launch and the junit agent uses ReportPortalService.

Possible to use ReportPortalListener with gradle?

In your README.md you have this maven pom setup:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-surefire-plugin</artifactId>
   <version>2.15</version>
   <configuration>
      <properties>
         <property>
            <name>listener</name>
            <value>com.epam.reportportal.junit.ReportPortalListener</value>
         </property>
      </properties>
   </configuration>
</plugin>

Is it possible to do this with gradle?

Thanks

No support for expected exceptions

Currently, any test that throws an exception is marked as a failure, even it the test specifies that the exception is expected. We need to add support for expected exceptions.

Maven test execution fails if specifying test suite

I'm using the example in https://github.com/reportportal/example-java-junit

when running the below it's working fine
C:\Users\talm\git\example-java-junit\v4>mvn test

Also the below works fine:
C:\Users\talm\git\example-java-junit\v4>mvn -Dtest=TestIssue4 test

This execution fails:
C:\Users\talm\git\example-java-junit\v4>mvn -Dtest=SimpleTestSuite1 test

[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.epam.rp.tests.SimpleTestSuite1
2018-06-17 14:14:06,265 [main] ERROR com.epam.reportportal.junit.ParallelRunningHandler - Unable start test suite: 'null'
com.epam.reportportal.exception.ReportPortalClientException: Report Portal returned error
Status code: 400
Status message: Bad Request
Error Message: Incorrect Request. [Field 'name' shouldn't be null.]
Error Type: INCORRECT_REQUEST
Stack Trace:
at com.epam.reportportal.service.ReportPortalErrorHandler.handleClientError(ReportPortalErrorHandler.java:47)
at com.epam.reportportal.restclient.endpoint.DefaultErrorHandler.handle(DefaultErrorHandler.java:73)

Display logs for @BeforeAll

No logs (we use log4j2 + JUnit5) related to @BeforeAll method or initialisation are available in ReportPortal UI.

If failure occurred in @BeforeAll (or earlier) - there is no chance to figure it out when evaluating Launches in ReportPortal UI

Junit 4 Agent documentation / README.md file should be updated

I have been digging around attempting to identify what the dependencies are supposed to be in order to use or attempt to use and test the updated agents for use in our environment.

I am assuming that I will only need the compile dependencies in the v5-beta branch and assuming that the transitive dependencies will be resolved without impact on existing projects.

The scope of the dependencies within the documentation should always be set to 'testCompile' or 'testImplementation' in order to exclude the EPAM and dependencies, logback.xml and properties files from being packaged with the resulting package utilizing the reportportal tooling. logback and properties files should be stored within the src/test/resources directory instead of src/main/resources.

Dependencies not found when using gradle

In my build.gradle I have:

repositories {
    mavenCentral()
    maven { url "http://dl.bintray.com/epam/reportportal" }
}

and

dependencies {
    compile (
        [group: 'junit', name:'junit', version:"4.12"],
         ...
        [group: 'com.epam.reportportal', name: 'agent-java-junit', version: "2.7.2"],
    )
}

When I try to compile I get:

* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find com.epam.reportportal:httpclient-repacked:1.0.2.
  Searched in the following locations:
      file:/Users/ndinoia/.m2/repository/com/epam/reportportal/httpclient-repacked/1.0.2/httpclient-repacked-1.0.2.pom
      file:/Users/ndinoia/.m2/repository/com/epam/reportportal/httpclient-repacked/1.0.2/httpclient-repacked-1.0.2.jar
      https://repo1.maven.org/maven2/com/epam/reportportal/httpclient-repacked/1.0.2/httpclient-repacked-1.0.2.pom
      https://repo1.maven.org/maven2/com/epam/reportportal/httpclient-repacked/1.0.2/httpclient-repacked-1.0.2.jar
      https://jcenter.bintray.com/com/epam/reportportal/httpclient-repacked/1.0.2/httpclient-repacked-1.0.2.pom
      https://jcenter.bintray.com/com/epam/reportportal/httpclient-repacked/1.0.2/httpclient-repacked-1.0.2.jar
  Required by:
      project : > project :Helpers > com.epam.reportportal:agent-java-junit:2.7.2 > com.epam.reportportal:client-java-core:2.7.1 > com.epam.reportportal:rest-client-core:1.0.4

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Note: I'm using it with a submodule gradle project

However I switched to agent-java-cucumber version 4.0.0 and it compiles OK

Test run is not finished

version 2.7.2
Sorry that the code snippets here are in Kotlin, should hopefully be easy to understand anyway.
I'm using ReportPortalListener as follows:

fun main(args: Array<String>) {
    val core = JUnitCore()
    core.addListener(ReportPortalListener())
    core.run(BasicLogin::class.java)
}

Test class is as follows:

class BasicLogin {
    @Test
    fun login_givenWrongCredentials_loginPageIsShown() {
        assertTrue(true)
    }

    @Test
    fun login_givenCorrectCredentials_mainMenuIsShown() {
        assertTrue(false)
    }
}

When I run this the test run in ReportPortal is added as expected, but it is never finished.

I have debugged a bit and can see that testFinished() method in ReportPortalListener has a check for # character in method name which fails. Seems to be addressed by this PR that has not been merged.

FATAL ERROR when processing javaagent

Hey guys,

I've been trying to integrate this into an existing project of mine for a little while but am hitting a nasty roadblock on the running of the javaagent introduced through the nordstrom dependency and access through the maven surefire plugin. Every time that I try and trigger a test execution through surefire i get the following error in my dumpstream:

Corrupted STDOUT by directly writing to native stream in forked JVM 1. Stream 'FATAL ERROR in native method: processing of -javaagent failed'.
java.lang.IllegalArgumentException: Stream stdin corrupted. Expected comma after third character in command 'FATAL ERROR in native method: processing of -javaagent failed'.
	at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$OperationalData.<init>(ForkClient.java:507)
	at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.processLine(ForkClient.java:210)
	at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:177)
	at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:88)
	at java.base/java.lang.Thread.run(Thread.java:835)

I'm attempting to utilise the ReportPortal log4j logger dependency as I already have log4j setup in my project, and I'm running with JUnit 4.12 (though I have removed this dependency in attempt to utilise this dependency instead).

I'm currently running on Windows10, with JDK12.0.2 and Maven 3.5.2. I have also tried downgrading to JDK8 (ncluding changing the maven compiler reference to bring this in line with the expected JDK), but this has no impact on the error produced.

The error produced is triggered when I attempt to run my maven tests with the following cli command via IntelliJ IDEA terminal:
mvn -pl :<project name> -am clean test -Dtest="<test name>"

Attached are the dumpstream logs generated on my latest run attempt. For reference I'm using the suggested plugins for maven-dependency-plugin (v3.1.1) and maven-surefire-plugin (v3.0.0-M3). Thanks in advance for any help with this.

2019-08-01T11-07-33_775.txt
2019-08-01T11-07-33_775-jvmRun1.txt

Retried tests don't reflect properly on RP

Tried 3 different ways to retry tests:

  1. surefire plugin option - surefire.rerunFailingTestsCount=1
  2. custom test rule
  3. junit foundation JUnitRetryAnalyzer

all works, but I'm not able to see retries on RP.

Empty test report

Hello,

When running the example-junit module the suite is reported but there is no content.

I am running against reportportal 5.3.5

Jose

Report portal marks tests as failed if AssumptionViolatedException thrown

Should mark test as skipped

    @Override
    public void testFailure(AtomicTest<FrameworkMethod> atomicTest, Throwable thrown) {
        reportTestFailure(atomicTest.getIdentity(), atomicTest.getRunner(), thrown);
    }

    @Override
    public void testAssumptionFailure(AtomicTest<FrameworkMethod> atomicTest, AssumptionViolatedException thrown) {
        reportTestFailure(atomicTest.getIdentity(), atomicTest.getRunner(), thrown);
    }

RP doesn't handle ExpectedException Rule

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Test 
    public void validateVersionNull() {
        thrown.expect(IllegalArgumentException.class);
        thrown.expectMessage("Version cannot be null");
        MessageVersion.validate(null, VERSION2, VERSION3);
    }

PastedGraphic-1

PastedGraphic-3

NullPointerException when using JUnitParams

Hello,

I receive the following error twice when I try to run a parameterized (using JUnitParams 1.1.1) test (the test itself passes but there are two mysterious tests called "classMethod" that fail)

java.lang.NullPointerException at com.epam.reportportal.junit.ParallelRunningHandler.buildStartTestItemRq(ParallelRunningHandler.java:307) at com.epam.reportportal.junit.ParallelRunningHandler.startTest(ParallelRunningHandler.java:136) at com.epam.reportportal.junit.ReportPortalListener.testStarted(ReportPortalListener.java:65) at com.nordstrom.automation.junit.RunAnnouncer.testStarted(RunAnnouncer.java:36) at org.junit.runner.notification.SynchronizedRunListener.testStarted(SynchronizedRunListener.java:49) at org.junit.runner.notification.RunNotifier$3.notifyListener(RunNotifier.java:121) at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72) at org.junit.runner.notification.RunNotifier.fireTestStarted(RunNotifier.java:118) at org.junit.internal.runners.model.EachTestNotifier.fireTestStarted(EachTestNotifier.java:42) at junitparams.internal.ParameterisedTestMethodRunner.runMethodInvoker(ParameterisedTestMethodRunner.java:45) at junitparams.internal.ParameterisedTestMethodRunner.runTestMethod(ParameterisedTestMethodRunner.java:40) at junitparams.internal.ParameterisedTestClassRunner.runParameterisedTest(ParameterisedTestClassRunner.java:146) at junitparams.JUnitParamsRunner.runChild$original$rG8AMkGf(JUnitParamsRunner.java:446) at junitparams.JUnitParamsRunner.runChild$original$rG8AMkGf$accessor$5RZ14YKA(JUnitParamsRunner.java) at junitparams.JUnitParamsRunner$auxiliary$n2dj1plO.call(Unknown Source) at com.nordstrom.automation.junit.LifecycleHooks.callProxy(LifecycleHooks.java:354) at com.nordstrom.automation.junit.RunChild.intercept(RunChild.java:62) at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java) at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:393) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run$original$oixVB9r6(ParentRunner.java:363) at org.junit.runners.ParentRunner.run$original$oixVB9r6$accessor$0pNyjhN1(ParentRunner.java) at org.junit.runners.ParentRunner$auxiliary$NmM4qtnw.call(Unknown Source) at com.nordstrom.automation.junit.LifecycleHooks.callProxy(LifecycleHooks.java:354) at com.nordstrom.automation.junit.Run.intercept(Run.java:66) at org.junit.runners.ParentRunner.run(ParentRunner.java) at org.junit.runners.BlockJUnit4ClassRunner.run$accessor$fckPfKMd(BlockJUnit4ClassRunner.java) at org.junit.runners.BlockJUnit4ClassRunner$auxiliary$uMgu60lQ.call(Unknown Source) at com.nordstrom.automation.junit.LifecycleHooks.callProxy(LifecycleHooks.java:354) at com.nordstrom.automation.junit.Run.intercept(Run.java:66) at org.junit.runners.BlockJUnit4ClassRunner.run(BlockJUnit4ClassRunner.java) at junitparams.JUnitParamsRunner.run$accessor$5RZ14YKA(JUnitParamsRunner.java) at junitparams.JUnitParamsRunner$auxiliary$HjeDmcBR.call(Unknown Source) at com.nordstrom.automation.junit.LifecycleHooks.callProxy(LifecycleHooks.java:354) at com.nordstrom.automation.junit.Run.intercept(Run.java:66) at junitparams.JUnitParamsRunner.run(JUnitParamsRunner.java) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy35.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:745)

Is JUnitParams supported?
Any suggestions on how to fix the problem?
Thanks

Not able to see the report

Hello, I'm trying to connect my project to report portal, but I'm having troubles to see anything on the report portal page.
Let me start saying that my project is a multi module maven project, so I have a pom parent and pom child, all the pom config you describe on the readme I did try it on the POM parent and on the child with not luck, the resources files could only be inside the child project, just because the parent project does not have the structure for it, other detail is that I am using IntelliJ for IDE.
Could you please help me to config this multi module project.
Structure:
Screen Shot 2021-12-16 at 11 48 15 AM

Suite run is having waiving issue

If I try to run the test with Suite.class runner, I get this error trace:

java.lang.IllegalStateException: Found multiple candidates for method describeChild(class org.junit.runners.BlockJUnit4ClassRunner) on class org.junit.runners.Suite : [protected org.junit.runner.Description org.junit.runners.Suite.describeChild(java.lang.Object),protected org.junit.runner.Description org.junit.runners.Suite.describeChild(org.junit.runner.Runner),protected org.junit.runner.Description org.junit.runners.ParentRunner.describeChild(java.lang.Object)] at org.apache.commons.lang3.reflect.MethodUtils.getMatchingMethod(MethodUtils.java:784) at org.apache.commons.lang3.reflect.MethodUtils.invokeMethod(MethodUtils.java:217) at org.apache.commons.lang3.reflect.MethodUtils.invokeMethod(MethodUtils.java:184) at com.nordstrom.automation.junit.LifecycleHooks.invoke(LifecycleHooks.java:412) at com.nordstrom.automation.junit.AtomicTest.<init>(AtomicTest.java:34) at com.nordstrom.automation.junit.RunAnnouncer.newAtomicTest(RunAnnouncer.java:119) at com.nordstrom.automation.junit.RunChild.intercept(RunChild.java:49) at org.junit.runners.Suite.runChild(Suite.java) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run$original$RnPkkO4k(ParentRunner.java:363) at org.junit.runners.ParentRunner.run$original$RnPkkO4k$accessor$9xjv0dUt(ParentRunner.java) at org.junit.runners.ParentRunner$auxiliary$VvzPshSo.call(Unknown Source) at com.nordstrom.automation.junit.LifecycleHooks.callProxy(LifecycleHooks.java:472) at com.nordstrom.automation.junit.Run.intercept(Run.java:58) at org.junit.runners.ParentRunner.run(ParentRunner.java) at org.junit.runners.Suite.run$accessor$EXX90XT2(Suite.java) at org.junit.runners.Suite$auxiliary$Q3fNu3Q4.call(Unknown Source) at com.nordstrom.automation.junit.LifecycleHooks.callProxy(LifecycleHooks.java:472) at com.nordstrom.automation.junit.Run.intercept(Run.java:58) at org.junit.runners.Suite.run(Suite.java) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at org.junit.runner.JUnitCore.run(JUnitCore.java:105) at org.junit.runner.JUnitCore.run(JUnitCore.java:94)

- Error indicates polymorphism waving issue.

Sample Suite class:

@RunWith(Suite.class)


@Suite.SuiteClasses({

TestClass_01.class,
TestClass_02.class

})


public class Batch_TestingOneAndTwo {


}


Using version:

com.epam.reportportal

agent-java-junit

5.0.0



Testing single class, like TestClass_01.class is working awesome! Very smooth, compared to version 4 branch! (well done!)

However, version 4 branch doesn't suffer from this issue. Version 4 sends data, but doesn't stop any testing properly.

The forked VM terminated without properly saying goodbye. VM crash or System.exit called?

While adding below plugin

org.apache.maven.plugins
maven-surefire-plugin
2.22.0


-javaagent:${com.nordstrom.tools:junit-foundation:jar}

i am getting this error.
Error occurred in starting fork, check output in log
Process Exit Code: 1

under surefire reports, below log is coming in file
Error opening zip file or JAR manifest missing : ${com.nordstrom.tools:junit-foundation:jar}

Please help here or help me with the steps to resolve this.

Step-by-step integration instructions need minor revisions

The step-by-step instructions documented in the README specify to add JUnit Foundation as a direct dependency. This is neither required nor desirable. JUnit Foundation is a transitive dependency, brought in by agent-java-junit. Remove the direct dependency.

Hard to use in a big project out of the box

Hi guys. I decided to try this promising project and to feed my local ReportPortal instance with the test results from JUnit tests. And I faced with the following problems:

  • It is not available from the Maven Central, so everybody has to add the custom repository to the config, which is not obvious.
  • It has a lot of dependencies (why there are so many?). And the worst thing is that it is using such libraries as Guava and Guice, that are known to be extremely incompatible from version to version. So it becomes almost impossible to solve the appearing depndency hell issues in the big proect with tons of dependencies...

Items doesn't finish in RP with agent-java-junit

trying to push junit tests to report portal, i do see my launches in RP, but they never finish
question has been raised in slack here: slack message

my configuration:

    <agent-java-junit-reportportal.version>2.7.0</agent-java-junit-reportportal.version>
    <logger-java-log4j-reportportal.version>4.0.1</logger-java-log4j-reportportal.version>
...
    <dependency>
      <groupId>com.epam.reportportal</groupId>
      <artifactId>agent-java-junit</artifactId>
      <version>${agent-java-junit-reportportal.version}</version>
    </dependency>
    <dependency>
      <groupId>com.epam.reportportal</groupId>
      <artifactId>logger-java-log4j</artifactId>
      <version>${logger-java-log4j-reportportal.version}</version>
    </dependency>
...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <configuration>
          <properties>
            <property>
              <name>listener</name>
              <value>com.epam.reportportal.junit.ReportPortalListener</value>
            </property>
          </properties>
        </configuration>
        <executions>
          <execution>
            <phase>test</phase>
          </execution>
        </executions>
      </plugin>
...

maven is showing some semver major dependency issues:

...
2.6.0	
net.bingobongo.zingo:zingo-jenkins:jar:1.1.119566
\- com.epam.reportportal:agent-java-junit:jar:2.7.0:compile
   \- com.epam.reportportal:client-java-core:jar:2.7.1:runtime
      \- (com.epam.reportportal:commons-model:jar:2.6.0:runtime - omitted for conflict with 4.0.3)

4.0.3	
net.bingobongo.zingo:zingo-jenkins:jar:1.1.119566
\- com.epam.reportportal:logger-java-log4j:jar:4.0.1:compile
   \- com.epam.reportportal:commons-model:jar:4.0.3:runtime
...

agent-java-junit4 does NOT report test results being run with @RunWith(PowerMockRunner.class) annotation

When executing test suites using any runner OTHER than PowerMockRunner are reported correctly. However, when PowerMockRunner is utilized, those tests classes are fail to report any results at all to ReportPortal.

ReportPortal installation is version 5 GA.

Agent-java-junit4 dependencies for all projects are:

com.epam.reportportal:agent-java-junit:4.1.8
com.epam.reportportal:logger-java-log4j:4.0.1
com.epam.reportportal:logger-java-logback:4.0.4
com.epam.reportportal:client-java:4.0.12
com.epam.reportportal:commons-model:4.2.0
com.nordstrom.tools:junit-foundation:9.2.0
com.google.inject:guice:4.2.2
io.reactivex.rxjava2:rxjava:2.1.6
org.apache.logging.log4j:log4j-api:2.10.0
org.apache.logging.log4j:log4j-core:2.10.0

The runner has been confirmed as the issue as one gradle project did not utilize the powermock api and did not report the results for the three methods contained within. This project was thus updated and so the runner was switched to utilize the @RunWith(MockJUnitRunner.class) and the results from this test class has since been reporting all test results correctly to ReportPortal.

Projects utilize a variety of mockito as well as PowerMock to execute tests. The hope here is that the agent will work with the PowerMockRunner class as well as the others.

Agent-java-junit v5.0.0-BETA-8 could not be tested due to the snapshot compile dependencies for commons-model and client-java.

If these dependencies can be supplied, I will be happy to attempt a run using the updated versions.

Thanks,
Scott

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.