org.apache.qpid.junit.extensions.listeners
Interface TKTestListener

All Superinterfaces:
junit.framework.TestListener
All Known Implementing Classes:
ConsoleTestListener, CSVTestListener, XMLTestListener

public interface TKTestListener
extends junit.framework.TestListener

TKTestListener is a listener interface for listeners that want to be informed of the run times of tests, the memory usage of tests, the 'size' parameters of parameterized tests and the begin and end events of complete test runs. TKTestResult is an example of a test result class that listeners interested in these events can be attached to. The timing(junit.framework.Test, long, Long), memoryUsed(junit.framework.Test, long, long, Long), parameterValue(junit.framework.Test, int, Long) and endTest(junit.framework.Test, Long) methods all accept on optional thread id parameter.

CRC Card
Responsibilities
Listen to test timings.
Listen to test memory usages.
Listen to parameterized test parameters.


Method Summary
 void addFailure(junit.framework.Test test, junit.framework.AssertionFailedError e, Long threadId)
          Called when a test completes to mark it as a test fail.
 void concurrencyLevel(junit.framework.Test test, int threads, Long threadId)
          Should be called every time a test completes with the current number of test threads running.
 void endBatch(Properties parameters)
          Notifies listeners of the end of a complete run of tests.
 void endTest(junit.framework.Test test, Long threadId)
          Called when a test completes.
 void memoryUsed(junit.framework.Test test, long memStart, long memEnd, Long threadId)
          Should be called every time a test completed with the amount of memory used before and after the test was run.
 void parameterValue(junit.framework.Test test, int parameter, Long threadId)
          Should be called every time a parameterized test completed with the int value of its test parameter.
 void properties(Properties properties)
          Notifies listeners of the tests read/set properties.
 void reset(junit.framework.Test test, Long threadId)
          Resets the test results to the default state of time zero, memory usage zero, parameter zero, test passed.
 void startBatch()
          Notifies listeners of the start of a complete run of tests.
 void timing(junit.framework.Test test, long nanos, Long threadId)
          Should be called every time a test completes with the run time of that test.
 void timing2(junit.framework.Test test, Long nanos, Long threadId)
          Optionally called every time a test completes with the second timing test.
 
Methods inherited from interface junit.framework.TestListener
addError, addFailure, endTest, startTest
 

Method Detail

reset

void reset(junit.framework.Test test,
           Long threadId)
Resets the test results to the default state of time zero, memory usage zero, parameter zero, test passed.

Parameters:
test - The test to resest any results for.
threadId - Optional thread id if not calling from thread that started the test method. May be null.

timing

void timing(junit.framework.Test test,
            long nanos,
            Long threadId)
Should be called every time a test completes with the run time of that test.

Parameters:
test - The name of the test.
nanos - The run time of the test in nanoseconds.
threadId - Optional thread id if not calling from thread that started the test method. May be null.

timing2

void timing2(junit.framework.Test test,
             Long nanos,
             Long threadId)
Optionally called every time a test completes with the second timing test.

Parameters:
test - The name of the test.
nanos - The second timing information of the test in nanoseconds.
threadId - Optional thread id if not calling from thread that started the test method. May be null.

memoryUsed

void memoryUsed(junit.framework.Test test,
                long memStart,
                long memEnd,
                Long threadId)
Should be called every time a test completed with the amount of memory used before and after the test was run.

Parameters:
test - The test which memory was measured for.
memStart - The total JVM memory used before the test was run.
memEnd - The total JVM memory used after the test was run.
threadId - Optional thread id if not calling from thread that started the test method. May be null.

parameterValue

void parameterValue(junit.framework.Test test,
                    int parameter,
                    Long threadId)
Should be called every time a parameterized test completed with the int value of its test parameter.

Parameters:
test - The test which memory was measured for.
parameter - The int parameter value.
threadId - Optional thread id if not calling from thread that started the test method. May be null.

concurrencyLevel

void concurrencyLevel(junit.framework.Test test,
                      int threads,
                      Long threadId)
Should be called every time a test completes with the current number of test threads running.

Parameters:
test - The test for which the measurement is being generated.
threads - The number of tests being run concurrently.
threadId - Optional thread id if not calling from thread that started the test method. May be null.

endTest

void endTest(junit.framework.Test test,
             Long threadId)
Called when a test completes. Success, failure and errors. This method should be used when registering an end test from a different thread than the one that started the test.

Parameters:
test - The test which completed.
threadId - Optional thread id if not calling from thread that started the test method. May be null.

addFailure

void addFailure(junit.framework.Test test,
                junit.framework.AssertionFailedError e,
                Long threadId)
Called when a test completes to mark it as a test fail. This method should be used when registering a failure from a different thread than the one that started the test.

Parameters:
test - The test which failed.
e - The assertion that failed the test.
threadId - Optional thread id if not calling from thread that started the test method. May be null.

startBatch

void startBatch()
Notifies listeners of the start of a complete run of tests.


endBatch

void endBatch(Properties parameters)
Notifies listeners of the end of a complete run of tests.

Parameters:
parameters - The optional test parameters to log out with the batch results.

properties

void properties(Properties properties)
Notifies listeners of the tests read/set properties.

Parameters:
properties - The tests read/set properties.


Licensed to the Apache Software Foundation