Quick Tutorial: Netbeans + Selenium + Hudson (Part 2)

In part 1 of this tutorial (I recommend to walk through it first) we created a simple web application, set up a Hudson server to build it and test it with Selenium. But we left with one major flaw: Hudson build the war file, but the JUnit test the job triggered was tesing an application already deployed to a Glassfish instance. Today we wipe out this problem, setting up a proper sequence of building, deploying and testing the application.

Pre-Requirements (same as in part 1):

  • Netbeans 6.9 (earlier versions certainly work as well)
  • Glassfish
    A local Glassfish that comes with Netbeans is good enough. I am using a Glassfish 3.0.1 running in a VirtualBox.
  • Hudson Server
    Download the war file from here. For the tutorial we will use a local standalone Hudson server.
  • Selenium RC
    Download from here.
  • Sourcecode Repository (SVN)
    In order to use Hudson, it is recommended to have a sourcecode repository like SVN to upload the code.

Tutorial:
Continue reading

Quick Tutorial: Netbeans + Selenium + Hudson

Selenium is one of the most powerful web application test tool I know. It supports a wide range of Browsers, Operating Systems, Languages and Test Frameworks (find all infos here). It takes a while to learn all the commands in the API that you can use to test your web application, fortunately there are some pluginsĀ  that help you to get started. Although I found it confusing to get started with Netbeans and Hudson, each having its own plugin, plus Firefox also offering a plugin, and some websites and tutorials leading in different directions (if you are in hurry like me).

This short tutorial walks you through the steps to get started in a few minutes.

Remarks:

  • A CI or build-server is usually headless, means there is no desktop, no Gnome, no GUI, so would not be possible for Selenium to start and control a browser. This tutorial assumes you run a build-server with desktop. At a later stage we will discuss the headless testing.
  • In this tutorial we will implement a simple JSP web application with 2 pages and create a JUnit test triggering the Selenium Test.
  • The Netbeans plugin and Hudson plugin for Selenium is not required for this tutorial.
  • The tutorial is created with Ubuntu as OS (Windows should be similar)

Pre-Requirements:

  • Netbeans 6.8 (earlier versions certainly work as well)
  • Glassfish
    A local Glassfish that comes with Netbeans is good enough.
  • Hudson Server
    Download the war file from here. For the tutorial we will use a local standalone Hudson server.
  • Selenium RC
    Download from here.
  • Sourcecode Repository (SVN)
    In order to use Hudson, it is recommended to have a sourcecode repository like SVN to upload the code.

Continue reading

Tutorial: Getting started with Netbeans and JUnit plus Cobertura and Hudson (Part 3)

Following part 1 and 2 which covered the JUnit test class creation and the coverage evaluation by Cobertura, we will add in part 3 another dimension: Automation. So far we run the tests manually, but we want to achieve a continuous integration and test environment.

Part 3 (Cobertura and Hudson)

Preparation:

Tutorial: Getting started with Netbeans and JUnit plus Cobertura (Part 1)

I believe strongly in testing. I saw companies and products without any automatic test frameworks and the slightest change to the codebase (often in the urgent ‘we-need-to-fix-it-now-and-give-to-the-customer-in-1hr’ mode) made parts of the product or modules prone to crashes because no one could test the changes against the complete application. In my current endevour to create a new product we embrace testing, though we dont practice TDD (test-driven-development), but at least we maximize the amount of automatic testing with tools/frameworks like Netbeans, Hudson, Cobertura and others. If you dont practice TDD, how can you judge how much of your codebase is really tested, even you assume all you business testcases are covered ?

The other day Code Coverage crossed my way (Thanks Chris!). Eager to find out how to “do it” or to “use it” I found a few tools suitable for the Netbeans environment. It actually drilled down to only one tool: Cobertura. It fits exactly into our landscape using Netbeans and Hudson and it is opensource.
To get started with Cobertura you should be familiar (a bit) with Netbeans, JUnit and Ant. The Cobertura website offers sufficient reference for all functions and introduction to get you started. But what I missed is a tutorial the start from the scratch using Netbeans and Cobertura. I found 3 references (I will add them at the end,) which are not complete or just not working for me), so let me share the most basic getting-started steps with you.
Please note: This is how I get started, it might not be complete, foolproof or even correct in all details. Please feel free to comment, correct or give other feedback !

Continue reading