| groovy.util.GroovyTestCase
All known Subclasses: org.codehaus.groovy.ant.GroovyTest, org.codehaus.groovy.antlr.treewalker.Java2GroovyTest, org.codehaus.groovy.classgen.BytecodeHelperTest, org.codehaus.groovy.classgen.CapitalizeTest, org.codehaus.groovy.tools.CompilerTest, org.codehaus.groovy.classgen.ReflectorGeneratorTest, org.codehaus.groovy.runtime.PropertyTest, org.codehaus.groovy.runtime.InvokerTest, org.codehaus.groovy.runtime.InvokeMethodTest, org.codehaus.groovy.antlr.SourceBufferTest, org.codehaus.groovy.runtime.DefaultGroovyMethodsTest, org.codehaus.groovy.tools.FileSystemCompilerTest, org.codehaus.groovy.syntax.TokenTest, org.codehaus.groovy.runtime.InvokeGroovyMethodTest, org.codehaus.groovy.syntax.parser.TestParserSupport, org.codehaus.groovy.runtime.InvokeConstructorTest, org.codehaus.groovy.runtime.TupleListTest, org.codehaus.groovy.antlr.treewalker.SourcePrinterTest, org.codehaus.groovy.classgen.DummyTestDerivation, org.codehaus.groovy.antlr.GroovySourceASTTest, org.codehaus.groovy.runtime.MethodFailureTest, org.codehaus.groovy.classgen.TestSupport,
GroovyTestCase | public class GroovyTestCase extends TestCase (Code) | | 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.
author: bob mcwhirter author: James Strachan author: Dierk Koenig (the notYetImplemented feature, changes to shouldFail) version: $Revision: 4201 $ |
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) | 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) | protected void | assertToString(Object value, String expected) | protected String | fixEOLs(String value) Returns a copy of a string in which all EOLs are \n. | public String | getMethodName() | public String | getName() | protected String | getTestClassName() | public static boolean | notYetImplemented(TestCase caller) Runs the calling JUnit test again and fails only if it unexpectedly runs.
This is helpful for tests that don't currently work but should work one day,
when the tested functionality has been implemented.
The right way to use it is:
public void testXXX() {
if (GroovyTestCase.notYetImplemented(this)) return;
... | public boolean | notYetImplemented() Convenience method for subclasses of GroovyTestCase, identical to
GroovyTestCase.notYetImplemented(this); . | protected String | shouldFail(Closure code) | protected String | shouldFail(Class clazz, Closure code) Asserts that the given code closure fails when it is evaluated
and that a particular exception is thrown. |
GroovyTestCase | public GroovyTestCase()(Code) | | |
assertArrayEquals | protected void assertArrayEquals(Object[] expected, Object[] value)(Code) | | Asserts that the arrays are equivalent and contain the same values
Parameters: expected - Parameters: value - |
assertContains | protected void assertContains(char expected, char[] array)(Code) | | Asserts that the array of characters contains a given char
Parameters: expected - expected character to be found Parameters: array - the array |
assertContains | protected void assertContains(int expected, int[] array)(Code) | | Asserts that the array of ints contains a given int
Parameters: expected - expected int Parameters: array - the array |
assertInspect | protected void assertInspect(Object value, String expected)(Code) | | 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 Parameters: expected - the expected String representation |
assertLength | protected void assertLength(int length, char[] array)(Code) | | Asserts that the array of characters has a given length
Parameters: length - expected length Parameters: array - the array |
assertLength | protected void assertLength(int length, int[] array)(Code) | | Asserts that the array of ints has a given length
Parameters: length - expected length Parameters: array - the array |
assertLength | protected void assertLength(int length, Object[] array)(Code) | | Asserts that the array of objects has a given length
Parameters: length - expected length Parameters: array - the array |
assertScript | protected void assertScript(String script) throws Exception(Code) | | Asserts that the script runs without any exceptions
Parameters: script - the script that should pass without any exception thrown |
assertToString | protected void assertToString(Object value, String expected)(Code) | | 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 Parameters: expected - the expected String representation |
fixEOLs | protected String fixEOLs(String value)(Code) | | Returns a copy of a string in which all EOLs are \n.
|
getName | public String getName()(Code) | | Overload the getName() method to make the test cases look more like AgileDox
(thanks to Joe Walnes for this tip!)
|
notYetImplemented | public static boolean notYetImplemented(TestCase caller)(Code) | | Runs the calling JUnit test again and fails only if it unexpectedly runs.
This is helpful for tests that don't currently work but should work one day,
when the tested functionality has been implemented.
The right way to use it is:
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.
when not itself already in the call stack |
shouldFail | protected String shouldFail(Closure code)(Code) | | Asserts that the given code closure fails when it is evaluated
Parameters: code - the message of the thrown Throwable |
shouldFail | protected String shouldFail(Class clazz, Closure code)(Code) | | Asserts that the given code closure fails when it is evaluated
and that a particular exception is thrown.
Parameters: clazz - the class of the expected exception Parameters: code - the closure that should fail the message of the expected Throwable |
|
|