Language

The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.15
OOoRunner test harness

lib
Class MultiMethodTest

java.lang.Object
  |
  +--lib.MultiMethodTest
Direct Known Subclasses:
MultiPropertyTest

public class MultiMethodTest
extends Object

The class supports method based interface tests development.

There are some points that should be fulfilled in a subclass to work correctly in the multi-method framework: 1. each subclass schould define a public field named oObj of type tested by the subclass, e.g. 'public XText oObj;'. That field will be initialized by the MultiMethodTest code with the instance of the interface to test. In a case of service testing the field type should be XPropertySet. 2. for the test of each method of the tested interface(or a property in the case of service testing) should be method with the following signature provided: 'public void _()', e.g. 'public void _getText()'. The methods will be called by MultiMethodText code using reflection API for each method in the interface description. 3. to set status for a call 'tRes.tested(String method, boolean result)' should be used. For example 'tRes.tested("getText()", true)'. Also 'tRes.assert(String assertion, boolean result)' call can be used. Note, that one can call the methods not neccesarily from the test for the tested method, but from other method tests too (in the MultiMethodTest subclass). See also TestResult and MultiMethodTest.tRes documentation. 4. the before() and after() methods can be overriden to perform some actions, accordingly, before and after calling the test methods. 5. besides tRes, there are some fields initialized in the MultiMethodTest, that can be used for implementing tests: - tEnv contains the environment tested - tParam contains parameters of the test - log a writer to log information about the test

See Also:
TestResult

Field Summary
protected  DescEntry entry
          Contains the Description for the test it.
protected  PrintWriter log
          Contains a writer to log an information about the interface testing, to allows for tests to access it.
protected  TestEnvironment tEnv
          Contains the TestEnvironment being tested, to allow for tests to access it.
protected  TestParameters tParam
          Contains the TestParameters for the tests, to allow for tests to access it.
protected  TestResult tRes
          Contains the TestResult instance for the interface test to collect information about methods test.
 
Constructor Summary
MultiMethodTest()
           
 
Method Summary
protected  void after()
          Is called after calling method tests.
protected  void before()
          Is called before calling method tests, but after initialization.
protected  void callMethod(String method)
          Just calls the method test.
 void disposeEnvironment()
          Disposes the current test environment, which was corrupted by the test.
 void disposeEnvironment(TestEnvironment tEnv)
          Disposes the test environment, which was corrupted by the test.
protected  void executeMethod(String method)
          Checks if the method was called, and if not, call it.
 String getInterfaceName()
           
protected  Method getMethodFor(String method)
          Finds a testing method for the method of the interface.
protected  Status getStatusFor(String method)
           
protected  String getTestedClassName()
           
protected  void invokeTestMethod(Method meth, String methName)
          Invokes a test method of the subclass using reflection API.
protected  boolean isCalled(String method)
          Checks if the method test has been already called.
protected  boolean isOptional(String method)
          Checks if the method is optional in the service.
protected  void requiredMethod(String method)
          Calling of the method indicates that the method test should be called.
 TestResult run(DescEntry entry, TestEnvironment tEnv, TestParameters tParam)
          Runs the interface test: its method tests.
protected  Status setField(String fieldName, Object value)
          Initializes fieldName of the subclass with value.
protected  void setStatus(String methName, Status methStatus)
          Sets a method status.
protected  void setSubStates(String msg)
          sets the substates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tEnv

protected TestEnvironment tEnv
Contains the TestEnvironment being tested, to allow for tests to access it.

tParam

protected TestParameters tParam
Contains the TestParameters for the tests, to allow for tests to access it.

entry

protected DescEntry entry
Contains the Description for the test it.

log

protected PrintWriter log
Contains a writer to log an information about the interface testing, to allows for tests to access it.

tRes

protected TestResult tRes
Contains the TestResult instance for the interface test to collect information about methods test.
Constructor Detail

MultiMethodTest

public MultiMethodTest()
Method Detail

disposeEnvironment

public void disposeEnvironment(TestEnvironment tEnv)
Disposes the test environment, which was corrupted by the test.
Parameters:
tEnv - the environment to dispose

disposeEnvironment

public void disposeEnvironment()
Disposes the current test environment, which was corrupted by the test.
See Also:
disposeEnvironment(TestEnvironment)

run

public TestResult run(DescEntry entry,
                      TestEnvironment tEnv,
                      TestParameters tParam)
Runs the interface test: its method tests. First, it initializes some of MultiMethodTest fields, like tRes, log, tEnv, etc. Then, it queries the tested interface and initializes 'oObj' field (defined in a subclass). Before calling method tests, before() method calles to allow initialization of s stuff before testing. Then, the method tests are called. After them, after() method is called, to allow cleaning up the stuff initialized in before() and test methods.
Parameters:
tEnv - the environment to test
ifcState - the interface test state
tParam - the parameters of the test
See Also:
before(), after()

before

protected void before()
Is called before calling method tests, but after initialization. Subclasses may override to perform actions before method tests.

after

protected void after()
Is called after calling method tests. Subclasses may override to perform actions after method tests.

getTestedClassName

protected String getTestedClassName()
Returns:
the name of the interface or the service tested.

setStatus

protected void setStatus(String methName,
                         Status methStatus)
Sets a method status.
Parameters:
methName - the method name to set status
methStatus - the status to set to the method

setSubStates

protected void setSubStates(String msg)
sets the substates

isOptional

protected boolean isOptional(String method)
Checks if the method is optional in the service.

isCalled

protected boolean isCalled(String method)
Checks if the method test has been already called.

getStatusFor

protected Status getStatusFor(String method)
Returns:
the status set to the method test, if it has been set, null otherwise.

requiredMethod

protected void requiredMethod(String method)
Calling of the method indicates that the method test should be called. The method checks this and if it is not called, calls it. If the method is failed or skipped, it throws StatusException.

executeMethod

protected void executeMethod(String method)
Checks if the method was called, and if not, call it. On contrary to requiredMethod(), he method doesn't check its status.

callMethod

protected void callMethod(String method)
Just calls the method test.

invokeTestMethod

protected void invokeTestMethod(Method meth,
                                String methName)
Invokes a test method of the subclass using reflection API. Handles the method results and sets its status.
Parameters:
meth - the subclass' method to invoke
methName - the name of the method

getMethodFor

protected Method getMethodFor(String method)
Finds a testing method for the method of the interface.
Returns:
the testing method, if found, null otherwise

getInterfaceName

public String getInterfaceName()
Returns:
the name of the interface tested

setField

protected Status setField(String fieldName,
                          Object value)
Initializes fieldName of the subclass with value.
Returns:
Status describing the result of the operation.

OOoRunner test harness

Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache, OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. The Apache feather logo is a trademark of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.