net.grinder.script
Class Test

java.lang.Object
  extended by net.grinder.common.AbstractTestSemantics
      extended by net.grinder.script.Test
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Test>, Test

public class Test
extends AbstractTestSemantics
implements java.io.Serializable

Scripts create Test instances which can then be used to wrap(java.lang.Object) other Jython objects.

To The Grinder, a test is a unit of work against which statistics are recorded. Tests are uniquely defined by a test number and may also have a description. Scripts can report many different types of thing against the same test, The Grinder will aggregate the results.

Creating a Test will automatically update The Grinder console with the test number and the description. If two Tests are created with the same number but a different description, the console will show the first description.

Author:
Philip Aston
See Also:
Serialized Form

Nested Class Summary
static interface Test.InstrumentationFilter
          Selective instrumentation.
 
Constructor Summary
Test(int number, java.lang.String description)
          Creates a new Test instance.
 
Method Summary
 java.lang.String getDescription()
          Get the test description.
 int getNumber()
          Get the test number.
 void record(java.lang.Object target)
          Instrument the supplied target object.
 void record(java.lang.Object target, Test.InstrumentationFilter filter)
          Version of record that allows selective instrumentation of an object.
 java.lang.Object wrap(java.lang.Object target)
          Creates a proxy script object that has the same interface as the passed object.
 
Methods inherited from class net.grinder.common.AbstractTestSemantics
compareTo, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Test

public Test(int number,
            java.lang.String description)
Creates a new Test instance.

Parameters:
number - Test number.
description - Test description.
Method Detail

getNumber

public final int getNumber()
Get the test number.

Specified by:
getNumber in interface Test
Returns:
The test number.

getDescription

public final java.lang.String getDescription()
Get the test description.

Specified by:
getDescription in interface Test
Returns:
The test description.

wrap

public final java.lang.Object wrap(java.lang.Object target)
                            throws NotWrappableTypeException
Creates a proxy script object that has the same interface as the passed object. The Grinder will delegate invocations on the proxy object to the target object, timing and record the success or failure of the invocation against the Test statistics. This method can be called many times, for many different targets.

Parameters:
target - Object to wrap.
Returns:
The proxy.
Throws:
NotWrappableTypeException - If the target object could not be wrapped.

record

public final void record(java.lang.Object target)
                  throws NonInstrumentableTypeException
Instrument the supplied target object. Subsequent calls to target will be recorded against the statistics for this Test.

Parameters:
target - Object to instrument.
Throws:
NonInstrumentableTypeException - If target could not be instrumented.

record

public final void record(java.lang.Object target,
                         Test.InstrumentationFilter filter)
                  throws NonInstrumentableTypeException
Version of record that allows selective instrumentation of an object.

The instrumenter will pass candidate items for instrumentation to the supplied filter. Only items for which the filter returns true will be instrumented.

The type of item passed to the filter depends upon the instrumenter, and in turn this depends on the type of target. For example, the Java DCR instrumenter will pass Methods to the filter.

Some instrumenters, including the Jython instrumenter, do not support selective instrumentation. If an instrumenter can handle the target , but does not support selective instrumentation, this method will throw NonInstrumentableTypeException. The non-selective version of record(Object) should be used instead.

Parameters:
target - Object to instrument.
filter - Filter that selects the parts of target to instrument.
Throws:
NonInstrumentableTypeException - If target could not be instrumented.
Since:
3.7