|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object junit.framework.Assert junit.framework.TestCase wheel.testing.WheelTestCase
public abstract class WheelTestCase
A JUnit-test case to extend your own tests when testing wheel components and pages. Example:
public class MyPageTest extends WheelTestCase { public void testSomething() { //first create an instance of the page/component you want to test MyPage page = new MyPage(); //possibly set some properties to initialize state etc. page.setPropertyX(...); //set the component on the "test bench" setComponent(page); //trigger rendering render(); //then do assertions with normal JUnit-assertions or then ones provided by WheelTestCase assertXPath("desired output", "//h1[@id='componentId']"); assertPresent("//div[@id='componentId']"); } }
Constructor Summary | |
---|---|
WheelTestCase()
|
Method Summary | |
---|---|
protected void |
addFormField(java.lang.String name,
java.lang.String value)
Adds field value to the mock form. |
protected void |
assertPresent(java.lang.String xpathExpression)
Checks that an element is present in the output html. |
protected void |
assertXpath(java.lang.String expectedValue,
java.lang.String xpathExpression)
Enables to make Xpath-based assertions on the html-code created when the component was rendered with a call to render() method. |
protected void |
createForm(java.lang.String id)
Creates a mock form where you can manually set values and then submit it to the component. |
protected StandaloneComponent |
getPage()
Returns the Page being used. |
protected void |
render()
Causes an immidiate rendering of the component. |
protected void |
reset()
Resets the html-output from the previous rendering. |
protected void |
setBasePackageForPages(java.lang.String basePackage)
By default the basePackage will be "wheel.testing" for components that are not Pages and the package-part of the class name for Page-instances. |
protected void |
setComponent(RenderableComponent component)
Pre-requirement for using any of the methods in this class. |
protected void |
setResult(org.w3c.dom.Document document)
|
protected void |
setUp()
|
protected void |
submitForm()
Submits the mock form created with createForm() method. |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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, failNotEquals, failNotSame, failSame, format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WheelTestCase()
Method Detail |
---|
protected void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
protected void render()
protected void createForm(java.lang.String id)
id
- Must match the componentId of the Form-component you want to mock.protected void addFormField(java.lang.String name, java.lang.String value)
name
- value
- protected void setComponent(RenderableComponent component)
component
- The component can be any as long as instanceof RenderableComponent is true.protected void submitForm()
protected void assertXpath(java.lang.String expectedValue, java.lang.String xpathExpression)
expectedValue
- Expected result of the xpath-expression.xpathExpression
- A valid Xpath-expressionprotected void assertPresent(java.lang.String xpathExpression)
xpathExpression
- A valid Xpath-expressionprotected void reset()
protected StandaloneComponent getPage()
protected void setBasePackageForPages(java.lang.String basePackage)
basePackage
- protected void setResult(org.w3c.dom.Document document)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |