public class GroovyTestCase
extends junit.framework.TestCase
Modifier and Type | Field and Description |
---|---|
protected static Logger |
log |
static String |
TEST_SCRIPT_NAME_PREFIX |
Constructor and Description |
---|
GroovyTestCase() |
Modifier and Type | Method and Description |
---|---|
protected void |
assertArrayEquals(Object[] expected,
Object[] value)
Asserts that the arrays are equivalent and contain the same values
|
protected void |
assertContains(char expected,
char[] array)
Asserts that the array of characters contains a given char
|
protected void |
assertContains(int expected,
int[] array)
Asserts that the array of ints contains a given int
|
static 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 string
|
protected void |
assertLength(int length,
char[] array)
Asserts that the array of characters has a given length
|
protected void |
assertLength(int length,
int[] array)
Asserts that the array of ints has a given length
|
protected void |
assertLength(int length,
Object[] array)
Asserts that the array of objects has a given length
|
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() |
boolean |
notYetImplemented()
Convenience method for subclasses of GroovyTestCase, identical to
GroovyTestCase.notYetImplemented(this); .
|
static boolean |
notYetImplemented(junit.framework.TestCase caller)
Runs the calling JUnit test again and fails only if it unexpectedly runs.
|
protected String |
shouldFail(Class clazz,
Closure code)
Asserts that the given code closure fails when it is evaluated
and that a particular exception type is thrown.
|
protected String |
shouldFail(Closure code)
Asserts that the given code closure fails when it is evaluated.
|
protected String |
shouldFailWithCause(Class clazz,
Closure code)
Asserts that the given code closure fails when it is evaluated
and that a particular exception type can be attributed to the cause.
|
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
protected static Logger log
public static final String TEST_SCRIPT_NAME_PREFIX
public String getName()
getName
in class junit.framework.TestCase
public String getMethodName()
protected void assertArrayEquals(Object[] expected, Object[] value)
expected
- value
- protected void assertLength(int length, char[] array)
length
- expected lengtharray
- the arrayprotected void assertLength(int length, int[] array)
length
- expected lengtharray
- the arrayprotected void assertLength(int length, Object[] array)
length
- expected lengtharray
- the arrayprotected void assertContains(char expected, char[] array)
expected
- expected character to be foundarray
- the arrayprotected void assertContains(int expected, int[] array)
expected
- expected intarray
- the arrayprotected void assertToString(Object value, String expected)
value
- the object to be output to the consoleexpected
- the expected String representationprotected void assertInspect(Object value, String expected)
value
- the object to be output to the consoleexpected
- the expected String representationprotected void assertScript(String script) throws Exception
script
- the script that should pass without any exception thrownException
protected String getTestClassName()
protected String shouldFail(Closure code)
code
- the closure that should failprotected String shouldFail(Class clazz, Closure code)
clazz
- the class of the expected exceptioncode
- the closure that should failprotected String shouldFailWithCause(Class clazz, Closure code)
If a match is found the error message associated with the matching exception is returned. If no match was found the method will fail.
clazz
- the class of the expected exceptioncode
- the closure that should failpublic static boolean notYetImplemented(junit.framework.TestCase caller)
public void testXXX() { if (GroovyTestCase.notYetImplemented(this)) return; ... the real (now failing) unit test }Idea copied from HtmlUnit (many thanks to Marc Guillemot). Future versions maybe available in the JUnit distro. The purpose of providing a 'static' version is such that you can use the feature even if not subclassing GroovyTestCase.
public boolean notYetImplemented()
GroovyTestCase.notYetImplemented(this);.
notYetImplemented(junit.framework.TestCase)