xjavadoc.codeunit
Class CodeTestCase

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--xjavadoc.codeunit.CodeTestCase
All Implemented Interfaces:
junit.framework.Test

public abstract class CodeTestCase
extends junit.framework.TestCase

CodeTestCase is a JUnit extension that will let you compare two sources (typically one we keep as test data and a generated one) on the API level or on the abstract syntax tree (AST) level. This is a lot more powerful than comparing on a character by character basis, because it's only "what matters" that is compared.

Author:
Aslak Hellesøy

Constructor Summary
CodeTestCase()
           
 
Method Summary
 void assertApiEquals(File expected, File actual)
          Asserts (tests) that the APIs of two sources are equal.
 void assertAstEquals(File expected, File actual)
          Asserts (tests) that the ASTs of two sources are equal.
 void assertEquals(File expected, File actual)
          Compares both API and AST.
protected  File getDir()
          Returns the directory where this class is located, provided that it's not in a jar.
protected  File getRootDir()
          Returns the root directory of the package hierarchy where this class is located, provided that it's not in a jar.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, 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
 

Constructor Detail

CodeTestCase

public CodeTestCase()
Method Detail

assertEquals

public void assertEquals(File expected,
                         File actual)
Compares both API and AST. Equivalent to calling assertAstEquals(java.io.File, java.io.File) and assertApiEquals(java.io.File, java.io.File).

Parameters:
expected - the expected source
actual - the actual source

assertAstEquals

public void assertAstEquals(File expected,
                            File actual)
Asserts (tests) that the ASTs of two sources are equal. Does not compare the contents (tokens) of the nodes, and is forgiving with respect to those.

Parameters:
expected - the expected source
actual - the actual source

assertApiEquals

public void assertApiEquals(File expected,
                            File actual)
Asserts (tests) that the APIs of two sources are equal. Does not go into the method bodies to see if the implementation is equal, and is therefore more relaxed than assertAstEquals.

Parameters:
expected - the expected source
actual - the actual source

getDir

protected File getDir()
Returns the directory where this class is located, provided that it's not in a jar. This is very useful for accessing the files you want to compare.

Returns:
the directory where this class is located.

getRootDir

protected File getRootDir()
Returns the root directory of the package hierarchy where this class is located, provided that it's not in a jar. This is very useful for accessing the files you want to compare.

Returns:
the root directory.


Copyright © 2002-2003 XDoclet Team. All Rights Reserved.