[ http://issues.apache.org/jira/browse/HARMONY-31?page=all ]

George Harley updated HARMONY-31:
---------------------------------

    Attachment: PerfDecorator.java

The attached file contains source for a type test.foo.utils.PerfDecorator that 
can be used to make straightforward timing measurements 
on JUnit test cases as they run. As the code is really only for illustrative 
purposes I send the information to stdout. 

Here is an example of how this class could be used to decorate a test suite 
(apologies in advance for any formatting 
problems that may occur)...

public static Test suite() {
  TestSuite suite = new TestSuite("My test suites");
  suite.addTestSuite(MyTestSuite.class);
                
  // Wrap the test suite "suite" inside the PerfDecorator...
  PerfDecorator pd = new PerfDecorator(suite);
  return pd;
}




> Move peformance timing of unit tests into a decorator class.
> ------------------------------------------------------------
>
>          Key: HARMONY-31
>          URL: http://issues.apache.org/jira/browse/HARMONY-31
>      Project: Harmony
>         Type: Improvement
>     Reporter: George Harley
>     Assignee: Geir Magnusson Jr
>     Priority: Minor
>  Attachments: PerfDecorator.java
>
> There has been some low-level discussion on the dev mailing list recently 
> about the inclusion of performance-related logging code near the top of a 
> unit test class inheritance hierarchy (see 
> com.openintel.drl.security.test.PerformanceTest in the HARMONY-16 
> contribution). This particular issue suggests an alternative way of adding in 
> timing code but without making it the responsibility of the unit tests 
> themselves and without the need to introduce a class in the inheritance 
> hierarchy. 
> The basic approach is to exploit the junit.extensions.TestDecorator type in 
> the JUnit API to add in timing behaviour before and after each test method 
> runs. This will be demonstrated with some simple sample code. 

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

Reply via email to