com.agical.rmock.extension.junit
Class AbstractStrategyTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.agical.rmock.extension.junit.AbstractStrategyTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
BasicJUnitStrategyTestCase

public abstract class AbstractStrategyTestCase
extends junit.framework.TestCase

A base for a strategy tests. A strategy test is different from a traditional JUnit test by allowing more flexibility. Where a traditional JUnit testCase simply offers a

  1. setup
  2. run
  3. tearDown

flow, a strategy test supports any setup that can be implemented from a run() method.

Apart from providing strategies, this TestCase also provides a Hub for configuration (this test configures itself by passing this to the hub within a begin/end scope.

Finally, this test also provides an assertThat(actual, expression) method and a Constraint factory reachable via the is attribute.


(c) 2005 Agical AB

Author:
joakim.ohlrogge

Field Summary
protected  ConstraintFactory is
          All expressions for the assertThatMethods are reachable from this factory.
 
Constructor Summary
AbstractStrategyTestCase(java.lang.String name)
           
AbstractStrategyTestCase(java.lang.String name, Hub hub)
          Takes the name of the test as a parameter.
 
Method Summary
 void assertThat(boolean result, Expression constraint)
           
 void assertThat(byte result, Expression constraint)
           
 void assertThat(char result, Expression constraint)
           
 void assertThat(double result, Expression constraint)
           
 void assertThat(float result, Expression constraint)
           
 void assertThat(int result, Expression constraint)
           
 void assertThat(long result, Expression constraint)
           
 void assertThat(java.lang.Object actual, Expression expression)
          Assert method that asserts that the object passed in the actual parameter passes the constraint passed in the expected parameter.
 void assertThat(short result, Expression constraint)
           
protected abstract  TestStep createStrategy(java.lang.String test)
          Implement this method to return a strategy to run for the given test.
 Hub getHub()
           
 StrategyRunner getStrategyRunner()
           
protected  Verifiable getVerifiable()
           
 void runBare()
          Gets and runs the strategy.
 void setAsserter(Assert asserter)
           
 void setStrategyRunner(StrategyRunner strategyRunner)
           
 void setTestCaseListener(TestCaseListener testCaseListener)
           
 void setVerifiable(Verifiable verifiable)
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

is

protected ConstraintFactory is
All expressions for the assertThatMethods are reachable from this factory. If you want to add more constraints just extend CostraintFactory and override this attribute with an instance of your new type.

Constructor Detail

AbstractStrategyTestCase

public AbstractStrategyTestCase(java.lang.String name)

AbstractStrategyTestCase

public AbstractStrategyTestCase(java.lang.String name,
                                Hub hub)
Takes the name of the test as a parameter. The name will be passed to the method creating the strategy. The name is most likel

Parameters:
name -
hub -
Method Detail

setStrategyRunner

public void setStrategyRunner(StrategyRunner strategyRunner)

getStrategyRunner

public StrategyRunner getStrategyRunner()

createStrategy

protected abstract TestStep createStrategy(java.lang.String test)
Implement this method to return a strategy to run for the given test.

Parameters:
test - The test to get the strategy for
Returns:
The strategy for the test.

runBare

public void runBare()
             throws java.lang.Throwable
Gets and runs the strategy.

Overrides:
runBare in class junit.framework.TestCase
Throws:
java.lang.Throwable

getHub

public Hub getHub()

assertThat

public void assertThat(java.lang.Object actual,
                       Expression expression)
Assert method that asserts that the object passed in the actual parameter passes the constraint passed in the expected parameter.

Parameters:
actual - The actual object that is checked against the expected constraint.
expression - The constraint that actual is expected to pass

assertThat

public void assertThat(boolean result,
                       Expression constraint)
See Also:
Assert#assertThat(boolean)

assertThat

public void assertThat(byte result,
                       Expression constraint)
See Also:
Assert#assertThat(byte)

assertThat

public void assertThat(char result,
                       Expression constraint)
See Also:
Assert#assertThat(char)

assertThat

public void assertThat(short result,
                       Expression constraint)
See Also:
Assert#assertThat(short)

assertThat

public void assertThat(int result,
                       Expression constraint)
See Also:
Assert#assertThat(int)

assertThat

public void assertThat(long result,
                       Expression constraint)
See Also:
Assert#assertThat(long)

assertThat

public void assertThat(float result,
                       Expression constraint)
See Also:
Assert#assertThat(float)

assertThat

public void assertThat(double result,
                       Expression constraint)
See Also:
Assert#assertThat(double)

setAsserter

public void setAsserter(Assert asserter)

setTestCaseListener

public void setTestCaseListener(TestCaseListener testCaseListener)

setVerifiable

public void setVerifiable(Verifiable verifiable)

getVerifiable

protected Verifiable getVerifiable()


Copyright © 2005-2009 Agical AB. All Rights Reserved.