Package groovy.test
Class GroovyTestCase
- java.lang.Object
-
- junit.framework.Assert
-
- junit.framework.TestCase
-
- groovy.test.GroovyTestCase
-
- All Implemented Interfaces:
junit.framework.Test
public class GroovyTestCase extends junit.framework.TestCase
A JUnit 3TestCase
base class in Groovy. In case JUnit 4 is used, seeGroovyAssert
.- See Also:
GroovyAssert
-
-
Field Summary
Fields Modifier and Type Field Description protected static Logger
log
static String
TEST_SCRIPT_NAME_PREFIX
-
Constructor Summary
Constructors Constructor Description GroovyTestCase()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
assertArrayEquals(Object[] expected, Object[] value)
Asserts that the arrays are equivalent and contain the same valuesprotected void
assertContains(char expected, char[] array)
Asserts that the array of characters contains a given charprotected void
assertContains(int expected, int[] array)
Asserts that the array of ints contains a given intstatic void
assertEquals(Object expected, Object actual)
static void
assertEquals(String message, Object expected, Object actual)
static void
assertEquals(String expected, String actual)
protected void
assertInspect(Object value, String expected)
Asserts that the value of inspect() on the given object matches the given text stringprotected void
assertLength(int length, char[] array)
Asserts that the array of characters has a given lengthprotected void
assertLength(int length, int[] array)
Asserts that the array of ints has a given lengthprotected void
assertLength(int length, Object[] array)
Asserts that the array of objects has a given lengthprotected void
assertScript(String script)
protected void
assertToString(Object value, String expected)
Asserts that the value of toString() on the given object matches the given text stringprotected 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()
boolean
notYetImplemented()
Convenience method for subclasses of GroovyTestCase, identical tostatic boolean
notYetImplemented(Object caller)
protected String
shouldFail(Closure code)
protected String
shouldFail(Class clazz, Closure code)
protected String
shouldFail(Class clazz, String script)
protected String
shouldFail(String script)
protected String
shouldFailWithCause(Class clazz, Closure code)
-
Methods inherited from class junit.framework.TestCase
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, run, run, runBare, runTest, setName, setUp, tearDown, toString
-
-
-
-
Field Detail
-
log
protected static Logger log
-
TEST_SCRIPT_NAME_PREFIX
public static final String TEST_SCRIPT_NAME_PREFIX
- See Also:
- Constant Field Values
-
-
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!)- Overrides:
getName
in classjunit.framework.TestCase
-
getMethodName
public String getMethodName()
-
assertArrayEquals
protected void assertArrayEquals(Object[] expected, Object[] value)
Asserts that the arrays are equivalent and contain the same values- Parameters:
expected
-value
-
-
assertLength
protected void assertLength(int length, char[] array)
Asserts that the array of characters has a given length- Parameters:
length
- expected lengtharray
- the array
-
assertLength
protected void assertLength(int length, int[] array)
Asserts that the array of ints has a given length- Parameters:
length
- expected lengtharray
- the array
-
assertLength
protected void assertLength(int length, Object[] array)
Asserts that the array of objects has a given length- Parameters:
length
- expected lengtharray
- the array
-
assertContains
protected void assertContains(char expected, char[] array)
Asserts that the array of characters contains a given char- Parameters:
expected
- expected character to be foundarray
- the array
-
assertContains
protected void assertContains(int expected, int[] array)
Asserts that the array of ints contains a given int- Parameters:
expected
- expected intarray
- the 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 consoleexpected
- 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 consoleexpected
- the expected String representation
-
getTestClassName
protected String getTestClassName()
-
fixEOLs
protected String fixEOLs(String value)
Returns a copy of a string in which all EOLs are \n.
-
notYetImplemented
public static boolean notYetImplemented(Object caller)
-
notYetImplemented
public boolean notYetImplemented()
Convenience method for subclasses of GroovyTestCase, identical toGroovyTestCase.notYetImplemented(this);
.- Returns:
false
when not itself already in the call stack- See Also:
notYetImplemented(java.lang.Object)
-
-