Skip to content
Alberto Scotto edited this page May 24, 2015 · 2 revisions

The Tests layer

JUnit vs. TestNG

selenium-tinafw is compatible both with JUnit and TestNG.

JUnit is recommended, though, as officially supported. As a side note, JUnit was chosen over TestNG for the elegant flexibility it provides (e.g. see Rules).

If you do choose JUnit, by extending JunitWebTest, you get the following features for free:

  • HTML reports with embedded screenshots for each failing test, thanks to HtmlReporter
  • the ability to run each test on many different browsers (or just one) by simply setting the property tinafw.browsers = chrome, firefox
  • the ability to retry a failed test for a given number of times (configurable). See TestRetrier
  • an automatic mechanism for closing browsers as soon as a test finishes, as well as the option to disable such a mechanism by setting a property. See BrowserManager

Writing web tests with JUnit

  1. Extend JunitWebTest.

  2. Initialize the JUnit rules provided. For each user involved in a test:

    • set the type of the browser to open: user.withBrowserType(browserType)
    • register the browser to BrowserManager: browserManager.registerBrowsers(browserType)
    • pass the browser to HtmlReporter: htmlReporter.setBrowser(browserType)

    You may define all of these steps in a fixture, aka a @Before method.

See SampleWebTest for a concrete example.

Clone this wiki locally