groovy.util
Class GroovyTestCase

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended bygroovy.util.GroovyTestCase
All Implemented Interfaces:
junit.framework.Test

public class GroovyTestCase
extends junit.framework.TestCase

A default JUnit TestCase in Groovy. This provides a number of helper methods plus avoids the JUnit restriction of requiring all test* methods to be void return type.

Version:
$Revision: 1.14 $
Author:
bob mcwhirter, James Strachan

Field Summary
protected  Logger log
           
 
Constructor Summary
GroovyTestCase()
           
 
Method Summary
protected  void assertArrayEquals(Object[] expected, Object[] value)
           
protected  void assertContains(char expected, char[] array)
           
protected  void assertContains(int expected, int[] array)
           
protected  void assertInspect(Object value, String expected)
          Asserts that the value of inspect() on the given object matches the given text string
protected  void assertLength(int length, char[] array)
           
protected  void assertLength(int length, int[] array)
           
protected  void assertLength(int length, Object[] array)
           
protected  void assertScript(String script)
          Asserts that the script runs without any exceptions
protected  void assertToString(Object value, String expected)
          Asserts that the value of toString() on the given object matches the given text string
protected  String fixEOLs(String value)
          Returns a copy of a string in which all EOLs are \n.
 String getMethodName()
           
 String getName()
          Overload the getName() method to make the test cases look more like AgileDox (thanks to Joe Walnes for this tip!)
protected  String getTestClassName()
           
protected  void shouldFail(Class clazz, Closure code)
           
protected  void shouldFail(Closure code)
          Asserts that the given code closure fails when it is evaluated
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, run, run, runBare, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected Logger log
Constructor Detail

GroovyTestCase

public GroovyTestCase()
Method Detail

getName

public String getName()
Overload the getName() method to make the test cases look more like AgileDox (thanks to Joe Walnes for this tip!)


getMethodName

public String getMethodName()

assertArrayEquals

protected void assertArrayEquals(Object[] expected,
                                 Object[] value)

assertLength

protected void assertLength(int length,
                            char[] array)

assertLength

protected void assertLength(int length,
                            int[] array)

assertLength

protected void assertLength(int length,
                            Object[] array)

assertContains

protected void assertContains(char expected,
                              char[] array)

assertContains

protected void assertContains(int expected,
                              int[] array)

assertToString

protected void assertToString(Object value,
                              String expected)
Asserts that the value of toString() on the given object matches the given text string

Parameters:
value - the object to be output to the console
expected - the expected String representation

assertInspect

protected void assertInspect(Object value,
                             String expected)
Asserts that the value of inspect() on the given object matches the given text string

Parameters:
value - the object to be output to the console
expected - the expected String representation

assertScript

protected void assertScript(String script)
                     throws Exception
Asserts that the script runs without any exceptions

Parameters:
script -
Throws:
Exception

getTestClassName

protected String getTestClassName()

shouldFail

protected void shouldFail(Closure code)
Asserts that the given code closure fails when it is evaluated

Parameters:
code -

shouldFail

protected void shouldFail(Class clazz,
                          Closure code)

fixEOLs

protected String fixEOLs(String value)
Returns a copy of a string in which all EOLs are \n.



Copyright © 2003-2004 The Codehaus. All Rights Reserved.