reportportal / agent-java-junit

Report Portal agent for JUnit 4
Apache License 2.0
11 stars 17 forks source link

Possible to use ReportPortalListener with gradle? #16

Closed nicodn closed 5 years ago

nicodn commented 5 years ago

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

DzmitryHumianiuk commented 5 years ago

@ndinoia yes, for sure.

@akoltochihin could you plz share example?

sbabcoc commented 5 years ago

The new implementation of agent-java-junit based on JUnit Foundation makes this super easy. This new agent currently lives in the v4 branch, but I'm understanding this will be merged into master any day now. Find the details of hooking up JUnit run listeners via JUnit Foundation here: https://github.com/Nordstrom/JUnit-Foundation/blob/master/README.md#support-for-standard-junit-runlistener-providers

nicodn commented 5 years ago

The new implementation of agent-java-junit based on JUnit Foundation makes this super easy. This new agent currently lives in the v4 branch, but I'm understanding this will be merged into master any day now. Find the details of hooking up JUnit run listeners via JUnit Foundation here: https://github.com/Nordstrom/JUnit-Foundation/blob/master/README.md#support-for-standard-junit-runlistener-providers

Thanks @sbabcoc! We've decided to hold off adopting ReportPortal for now due to conflicts with our custom jUnit parameterized runners but I'll make a note to take a look at this down the road.

sbabcoc commented 5 years ago

You're in luck! The new JUnit agent will work with your parameterized runner, because it hooks in via a Java agent instead of requiring a custom runner. Give it a try to see how it works for you. https://github.com/Nordstrom/JUnit-Foundation#how-to-enable-notifications JUnit Foundation hooks into the test execution flow by intercepting core JUnit methods:

JUnit Foundation provides run-time access to core objects and classes that would otherwise be unavailable. For example, LifecycleHooks.getRunnerFor(TestClass) returns the test runner that owns the specified test class object. In your example, this would be your custom parameterized runner.

sbabcoc commented 5 years ago

BTW - I never provided a link to the v4 agent: https://github.com/reportportal/agent-java-junit/tree/v4

sbabcoc commented 5 years ago

@nicodn Another bonus for your parameterized tests! You can record the test parameters with your results by implementing the ArtifactParams interface. Take a look at ParameterizedTest for an example of how this works.