Skip to content

Latest commit

 

History

History
114 lines (88 loc) · 7.93 KB

README.md

File metadata and controls

114 lines (88 loc) · 7.93 KB

Making Testing Groovy

This project looks at a simple blog application and numerous tools and techniques to test it. In that sense, the examples focus on web testing (and to some degree acceptance testing) - having said that, many of the techniques are generally applicable and can be applied to any kind of testing for any kind of application or system. The examples are mostly Groovy based but again, the ideas transfer across to some degree to other modern languages. The examples are designed to be runnable 'out-of-the-box' by cutting and pasting the code into the GroovyConsole which comes with any typical Groovy installation. Alternatively, they can be run from your favorite IDE (tested with IDEA community edition and, to a lesser degree, Eclipse).

Note: All examples have been tested using Java 8 only unless otherwise noted within the example. Examples may work with other versions of Java but that probably hasn't been tested. The examples use the Groovy version specified in build.gradle unless otherwise noted.

Application Under Test

The application is a simple web-based blogging system. It is a little novel in that it combines in a single Groovy file a Spring/standalone GORM/Jetty application. Just follow the instructions within the project directory to fire up the application. The application can be found in the AppUnderTest subproject. You can also play with a standalone GORM with the same model but no web later (see the GormApp project).

Basic Test Automation

  • The Vanilla examples illustrate how to test the blogging application using basic low-level Groovy/Java features. No testing framework is used.
  • The HtmlUnit examples illustrate how to use HtmlUnit as the test 'driver' to test the blogging application. Various test 'runners' are illustrated: plain groovy, JUnit 3/4/5, TestNG and GroovyTestCase. Various enhancements are examined: a test case abstraction, a fluent test api and a testing DSL.
  • The JWebUnit examples illustrate how to use JWebUnit as the test 'driver' to test the blogging application. which supports IE, Firefox/Mozilla and Safari.
  • The Geb examples illustrate how to use Geb to test the blogging application.
  • The WebTest examples illustrate how to use WebTest to test the blogging application. (Moved to the archive branch)
  • The SeleniumServer examples illustrate how to use Selenium Server (previously called Selenium RC or sometimes referred to as Selenium 1) to test the blogging application.
  • The WebDriver examples illustrate how to use Selenium WebDriver (sometimes referred to as Selenium 2) to test the blogging application.
  • The HttpBuilder examples illustrate how to use HttpBuilder as the test 'driver' to test the blogging application.
  • The HttpBuilderNG examples illustrate how to use HttpBuilder-NG as the test 'driver' to test the blogging application. This is a fairly low-level api - it gives easy access to status codes, cookies and other low-level information if you require it.

Towards more maintainable Tests

  • The Geb and WebDriver examples illustrate ways to separate the concerns of user interface (or view) and logical model. This is done by writing tests in terms of a logical model and as a separate activity defining the user interface aspects corresponding to the model. One technique illustrated is the use of Page objects.

Towards more readable Tests

  • The Spock examples illustrate how to use Spock to test the blogging application.
  • The EasyB examples illustrate how to use EasyB to test the blogging application.
  • The JBehave examples illustrate how to use JBehave to test the blogging application.
  • The CucumberJava and CucumberGroovy examples illustrate how to use Cucumber to test the blogging application.
  • The HtmlUnit examples illustrate some fluent api and DSL usage.
  • The Slim examples illustrate writing your tests FitNesse style in a wiki with the fixture code using Groovy. (Moved to the archive branch) These examples also illustrate a number of FitNesse related tools including HtmlFixture, Xebium and ZiBreve.
  • The Concordion examples illustrate how to use Concordion to test the blogging application.
  • The RobotFramework examples illustrate how to use Robot Framework to test the blogging application.
  • The Tumbler example illustrates using the Tumbler BDD tool.
  • The Serenity examples illustrate using the Serenity BDD tool.

Advanced Test Case/Data Selection

  • The DataDriven examples illustrate the data-driven capabilities of JUnit4 and TestNG.
  • The CombinationsAndPairs examples examine the idea of testing combinations of parameters where the combinations are automatically generated. Also looks at the idea of pairwise testing (also known as orthogonal array testing or all pairs testing).
  • The Choco examples illustrate how to use Choco to test the blogging application using conditions expressed as logic constraints.
  • The ModelJUnit examples illustrate how to use ModelJUnit to generate test cases from an 'external' model of an application/system.
  • The PropertyBased examples illustrate how to use QuickCheck and similar libraries to generate test cases using random and generated data values.
  • The GPars examples illustrate how to run tests in parallel

Other useful testing tools

  • The Ersatz example uses the Ersatz http proxy instead of a real http server
  • The Dyna4jdbc example uses the Dyna4jdbc scripted database driver

Requirements

Required:

  • This lab assumes you have JDK8 installed. If you don't already have it, see the links below.

Recommended:

  • An IDE such as Intellij IDEA (see links below)
  • If not using an IDE with Git built-in, command-line Git is recommended (alternatively download the associated zip with this project)

Other useful tools

Hints for using

Firstly, clone this repo from github.

From Intellij:

  • Open the build.gradle file in the root directory
  • Select 'Open as project'
  • Accept all the default settings in the options dialog.

Eclipse users might want to try ./gradlew eclipse but this isn't fully tested.