Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.swtbot.swt.finder
Class SWTBotTestCase

    java.lang.Object
      junit.framework.Assert
          junit.framework.TestCase
              org.eclipse.swtbot.swt.finder.SWTBotTestCase

All Implemented Interfaces:
  junit.framework.Test

Direct Known Subclasses:
  SWTBotEclipseTestCase

    public abstract class SWTBotTestCase

extends junit.framework.TestCase

The SWTBotTestCase extends the JUnit TestCase to provide extra capabilities for comparing widgets and other UI items.

Since:
  1.0
Version:
  $Id$
Author:
  Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
See Also:
  `SWTBotAssert`

Field Summary
`protected SWTBot` | `bot` An instance of SWTBot that may be used by extending items.

Constructor Summary
`SWTBotTestCase()`

Method Summary
`static void` | `assertContains(String needle, String hayStack)` Asserts that the `needle` is contained within the `hayStack`.
`static void` | `assertDoesNotContain(String needle, String hayStack)` Asserts that the `needle` is not present in the `hayStack`.
`static void` | `assertEnabled(AbstractSWTBot<? extends Widget> widget)` Asserts that the widget is enabled.
`static void` | `assertMatchesRegex(String regex, AbstractSWTBot<? extends Widget> actual)` Assert that the widget text matches the regex.
`static void` | `assertMatchesRegex(String regex, String actual)` Assert that the widget text matches the regex.
`static void` | `assertMatchesRegex(String regex, Widget actual)` Assert that the widget text matches the regex.
`static void` | `assertNotEnabled(AbstractSWTBot<? extends Widget> widget)` Asserts that the widget is not enabled.
`static void` | `assertNotSameWidget(String message, Widget expected, Widget actual)` Asserts the two widgets do not refer to the same object.
`static void` | `assertNotSameWidget(Widget expected, Widget actual)` Asserts that two widgets do not refer to the same object.
`static void` | `assertNotVisible(AbstractSWTBot<? extends Widget> widget)` Asserts that the widget is not visible.
`static void` | `assertSameWidget(String message, Widget expected, Widget actual)` Asserts that two widgets refer to the same widgets.
`static void` | `assertSameWidget(Widget expected, Widget actual)` Asserts that two widgets refer to the same widget.
`static void` | `assertText(String expected, AbstractSWTBot<? extends Widget> widget)` Assert that the given string is the same as the widgets text.
`static void` | `assertText(String expected, Widget widget)` Assert that the given string is the same as the widgets text.
`static void` | `assertTextContains(String expected, AbstractSWTBot<? extends Widget> widget)` Assert that the text on the widget contains the expected text.
`static void` | `assertTextContains(String expected, Widget widget)` Assert that the text on the widget contains the expected text.
`static void` | `assertTextDoesNotContain(String expected, AbstractSWTBot<? extends Widget> widget)` Assert that the text on the widget does not contain the expected text.
`static void` | `assertTextDoesNotContain(String expected, Widget widget)` Assert that the text on the widget does not contain the expected text.
`static void` | `assertVisible(AbstractSWTBot<? extends Widget> widget)` Asserts that the widget is visible.
`static boolean` | `captureScreenshot(String fileName)` Allows the screen shot to be captured and saved to the given file.
`static void` | `pass()` A helper to explicitly convey that the test has passed.
`void` | `runBare()` Overides the runBare method to TestCase to add the ability to capture a screen shot when an error is thrown.

Methods inherited from class junit.framework.TestCase
`countTestCases, createResult, getName, run, run, 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, failNotEquals, failNotSame, failSame, format`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### bot

    protected SWTBot bot

  An instance of SWTBot that may be used by extending items.

  Since:
    1.1

Constructor Detail

### SWTBotTestCase

    public SWTBotTestCase()

Method Detail

### assertNotSameWidget

    public static void assertNotSameWidget(Widget expected,
                                           Widget actual)

  Asserts that two widgets do not refer to the same object.

  Parameters:
    `expected` - the object you don't expect
    `actual` - the object to compare to unexpected
  See Also:
    `Assert.assertNotSame(String, Object, Object)`

### assertNotSameWidget

    public static void assertNotSameWidget(String message,
                                           Widget expected,
                                           Widget actual)

  Asserts the two widgets do not refer to the same object. The message will be used if the test fails.

  Parameters:
    `message` - the identifying message or null for the AssertionError
    `expected` - the object you don't expect
    `actual` - the object to compare to unexpected

### assertContains

    public static void assertContains(String needle,
                                      String hayStack)

  Asserts that the `needle` is contained within the `hayStack`.

  Parameters:
    `needle` - the text to search in the `hayStack`.
    `hayStack` - the text to look within.

### assertDoesNotContain

    public static void assertDoesNotContain(String needle,
                                            String hayStack)

  Asserts that the `needle` is not present in the `hayStack`.

  Parameters:
    `needle` - the text to search in the `hayStack`.
    `hayStack` - the text to look within.

### assertSameWidget

    public static void assertSameWidget(Widget expected,
                                        Widget actual)

  Asserts that two widgets refer to the same widget.

  Parameters:
    `expected` - the expected widget
    `actual` - the widget to compare to expected

### assertSameWidget

    public static void assertSameWidget(String message,
                                        Widget expected,
                                        Widget actual)

  Asserts that two widgets refer to the same widgets.

  Parameters:
    `message` - the identifying message or `null` for the AssertionError
    `expected` - the expected widget
    `actual` - the widget to compare to expected

### pass

    public static void pass()

  A helper to explicitly convey that the test has passed. Does nothing.

### assertText

    public static void assertText(String expected,
                                  Widget widget)

  Assert that the given string is the same as the widgets text.

  Parameters:
    `expected` - the expected text
    `widget` - the widget to get the text from to compare.

### assertText

    public static void assertText(String expected,
                                  AbstractSWTBot<? extends Widget> widget)

  Assert that the given string is the same as the widgets text.

  Parameters:
    `expected` - the expected text
    `widget` - the widget to get the text from to compare.

### assertTextContains

    public static void assertTextContains(String expected,
                                          Widget widget)

  Assert that the text on the widget contains the expected text.

  Parameters:
    `expected` - the expected text.
    `widget` - the widget

### assertTextContains

    public static void assertTextContains(String expected,
                                          AbstractSWTBot<? extends Widget> widget)

  Assert that the text on the widget contains the expected text.

  Parameters:
    `expected` - the expected text
    `widget` - the widget

### assertTextDoesNotContain

    public static void assertTextDoesNotContain(String expected,
                                                Widget widget)

  Assert that the text on the widget does not contain the expected text.

  Parameters:
    `expected` - the expected text
    `widget` - the widget

### assertTextDoesNotContain

    public static void assertTextDoesNotContain(String expected,
                                                AbstractSWTBot<? extends Widget> widget)

  Assert that the text on the widget does not contain the expected text.

  Parameters:
    `expected` - the expected text
    `widget` - the widget

### assertEnabled

    public static void assertEnabled(AbstractSWTBot<? extends Widget> widget)

  Asserts that the widget is enabled.

  Parameters:
    `widget` - the widget.

### assertNotEnabled

    public static void assertNotEnabled(AbstractSWTBot<? extends Widget> widget)

  Asserts that the widget is not enabled.

  Parameters:
    `widget` - the widget.

### assertVisible

    public static void assertVisible(AbstractSWTBot<? extends Widget> widget)

  Asserts that the widget is visible.

  Parameters:
    `widget` - the widget.

### assertNotVisible

    public static void assertNotVisible(AbstractSWTBot<? extends Widget> widget)

  Asserts that the widget is not visible.

  Parameters:
    `widget` - the widget.

### runBare

    public void runBare()
                 throws Throwable

  Overides the runBare method to TestCase to add the ability to capture a screen shot when an error is thrown. The screenshot is saved to a file in the current run directory inside a folder called `screenshots` that gets created if it does not already exist. The screenshot will be saved with the file `screenshots/screenshot-<classname>.<testname>.png`

  Overrides:
    `runBare` in class `junit.framework.TestCase`
  Throws:
    `Throwable` - Thrown if an error occurs during running.
  See Also:
    `TestCase.runBare()`

### captureScreenshot

    public static boolean captureScreenshot(String fileName)

  Allows the screen shot to be captured and saved to the given file.

  Parameters:
    `fileName` - the filename to save screenshot to.
  Returns:
    `true` if the screenshot was created and saved, `false` otherwise.
  See Also:
    `SWTUtils.captureScreenshot(String)`

### assertMatchesRegex

    public static void assertMatchesRegex(String regex,
                                          AbstractSWTBot<? extends Widget> actual)

  Assert that the widget text matches the regex.

  Parameters:
    `regex` - the regex.
    `actual` - the widget.

### assertMatchesRegex

    public static void assertMatchesRegex(String regex,
                                          Widget actual)

  Assert that the widget text matches the regex.

  Parameters:
    `regex` - the regex.
    `actual` - the widget.

### assertMatchesRegex

    public static void assertMatchesRegex(String regex,
                                          String actual)

  Assert that the widget text matches the regex.

  Parameters:
    `regex` - the regex.
    `actual` - the widget.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD