[jboss-jira] [JBoss JIRA] Commented: (JGRP-850) Fix output leak in testNG test reporting

Richard Achmatowicz (JIRA) jira-events at lists.jboss.org
Tue Oct 28 12:53:21 EDT 2008


    [ https://jira.jboss.org/jira/browse/JGRP-850?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12435810#action_12435810 ] 

Richard Achmatowicz commented on JGRP-850:
------------------------------------------

After some investigation on the tesNG forums, it turns out that the interface

public interface IInvokedMethodListener extends ITestNGListener {
 void beforeInvocation(IInvokedMethod method, ITestResult testResult);
 void afterInvocation(IInvokedMethod method, ITestResult testResult);

}

is not old, but in fact *new*.  It appears in a version of testNG which Vladimir downloaded the other day - testng-5.8.

To get around the problem of leaking output described earlier, just do the following to the class org.jgroups.util.JUnitXmlReporter:

(i) indicate in the class definition that it implements IInvokedMethodListener
(ii) add in two methods beforeMethod() and afterMethod() which make up the interface IInvokedMethodListener

    /** Called before any method is invoked */
   public void beforeInvocation(IInvokedMethod method, ITestResult tr) {
   }

   /** Called after method is invoked */
   public void afterInvocation(IInvokedMethod method, ITestResult tr) {
   }

(iii) move the body of the method  onStartTest() so that it becomes the body of beforeInvocation(). This means that the check for setting
the thread local variable will be performed before every method invocation.

(iv) add the import statements
import org.testng.IInvokedMethod ;
import org.testng.IInvokedMethodListetner ;

I tried this out - works OK. Will commit the changes.


> Fix output leak in testNG test reporting
> ----------------------------------------
>
>                 Key: JGRP-850
>                 URL: https://jira.jboss.org/jira/browse/JGRP-850
>             Project: JGroups
>          Issue Type: Bug
>            Reporter: Richard Achmatowicz
>            Assignee: Richard Achmatowicz
>            Priority: Minor
>             Fix For: 2.7
>
>
> org.jgroups.util.JUnitXmlReporter is a class which takes output from testNG test cases and prepares xml test case reports in JUnit-compatible format. These xml files are then used to generate JUnit style reports.
> At present, output from test case methods which execute before the main test case (testNG configurator methods, such as @BeforeSuite, @AfterSite, etc) written to System.out and System.err is leaking to the console and not being captured with the rest of the testNG output. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list