• No results found

Continuous Integration

N/A
N/A
Protected

Academic year: 2021

Share "Continuous Integration"

Copied!
20
0
0

Loading.... (view fulltext now)

Full text

(1)

WITH

FITNESSE AND SELENIUM

Continuous Integration

By Brian Kitchener

[email protected]

(2)
(3)

Intro

 Who am I?

 Overview

Continuous Integration

The Tools

Selenium Overview

Fitnesse Overview

Data Dependence

My Solution

Demo

(4)

What is CI?

From Wikipedia:

Continuous Integration (CI) implements a continuous processes of applying quality control - small pieces of effort, applied frequently. Continuous integration aims to improve the quality of software, and to reduce the time taken to deliver it, by replacing the traditional practice of applying quality control after completing all development.

In English:

automatic code integration and validation!

What do we need?

A Build Server to control everything and store reporting

A development/deployment process that supports being automated.

Scripts to do the work

One or more test frameworks to test the code (nUnit, Fitnesse, Selenium)

A minimal set of tests that cover a broad scope of functionality

What do we get?

Automatic testing and validation for each code change

Immediate and automatic isolation of the cause

Up-to-date, centralized reporting

You know who broke it, and who needs to fix it.

You never will test a broken environment again.

(5)

The Tools

 Build Server (Hudson) Runs our Tests

Unit Tests

Tests the individual functions

Fitnesse Tests:

Database (DB Fit)

API calls

Web Services

Selenium Tests:

UI Issues

Functionality problems

Javascript Errors

(6)

Selenium IDE

Firefox only plug- in, no other

browsers.

Step based testing, no complex functionality

Record and Playback

Fast test prototyping

Troubleshooting

Can be run from Hudson using a plug-in.

(7)

Selenium Core

Stored on your website’s web server

Executable via a url

Supports any browser

Tests stored in a central repository

Has problems supporting https or changing domains

(8)

Selenium RC

Client/server java application needs to be installed

Supports any Browser/OS combination

Test can be run locally or remotely

Controlled and executed through xUnit

Test written in your favorite programming language/IDE (C#, java, python, ruby)

Access to full features of that language and any extra libraries

[Test]

public void testGoogle() {

selenium.Open(“http://www.google.com/");

selenium.waitForPageToLoad(“30000”);

selenium.Type("q", "selenium");

selenium.Click("btnG");

selenium.waitForPageToLoad(“30000”);

Assert.IsTrue(selenium.IsTextPresent("Selenium web application testing system"));

}

(9)

Selenium Grid

Distributed parallel testing

More setup, but faster execution

Run on multiple machines

simultaneously

Generates more load

(10)

Pros Cons

Injects itself as javascript into the page object

Any browser that supports javascript supports selenium

The ONLY tool that can work with any browser/os

Extremely fast execution time

Direct access to page objects

Doesn’t hijack your computer

You can do other things while its running

Full access to outside libraries

If you need something else, you can code it.

Pick your language

Record in IDE and convert to RC.

Easier for non-coders

Fast test prototyping

Troubleshooting

Open source tools can be customized

Injects itself as javascript into the page object

Non Firefox browsers don’t always work perfectly

It can’t see anything outside of the page

Can’t click on the menu, navigation buttons, or any extra windows

Predefined routines reproduce this functionality

XSS Limitations

Changing domains/https

It “fakes” a lot

It doesn’t use the mouse/keyboard

Doesn’t really click on anything

Accesses each item directly and calls a function

Can bypass front end functionality such as

“onclick”

Can access hidden items even if you don’t want it to

Some functionality can’t be automated

But can be gotten around

Open source tools require a lot of coding

How Selenium Works

(11)

Fitnesse Overview

 What is Fitnesse?

Fitnesse = FIT + Wiki

FIT : Framework for Integrated Testing - The engine that translates tables into actions

Wiki: The GUI that allows the user to edit and run tests

A website that allows us to create, edit, and run tests.

The tests must be written as a table

Each row is a test

(12)

Fitnesse continued

Typically used to test an application or database directly, without accessing the GUI.

Calls a Web service, API, DB Procedure

Test the Business Logic directly.

We don’t have to try to “trick” the ui into an incorrect state

Typically more stable than GUI testing as less functionality changes over time

Requires the creation of a Fixture which knows how to translate the test into an action.

The fixtures are many times written by the application developers

Some “standard” fixtures exist, such as the RESTFixture for testing REST based services

Once written, the fixtures can be largely ignored

Different fixtures allow different functionality.

(13)

Fitnesse continued

Typical data driven testing - same test multiple times for all data types

Boundary conditions

Error code checking

Business Logic

Acceptance Testing-

Wiki style input allows non-coders to develop and run tests.

Business and Product personnel can (theoretically) write acceptance tests

However it requires a knowledge of the AUT

GUI testing is possible with appropriate fixture

Can’t test for javascript errors without a GUI test

However selenium is more robust

(14)

Fitnesse

(15)

Fitnesse pros and cons

 Tests are editable and executable from a web page.

 Uses Xpath.

 Can generate fake bugs (stuff looks broken because of a Fitnesse problem)

 Test maintenance can be time consuming

Everything is a text document

Same tests many different places

 Global variables allow you to change url, user, etc very easily

 Many tests can require unique information (id, name) that can change in different environments.

 Run-time variables allow you to create more dynamic tests.

 Knowing what data should be returned can be troublesome

 Can generate exact error-causing conditions

 Useless if your application sucks

(16)

Data Dependence

The biggest problem with automation is changing data

Time changes, items expire, dates change.

Need to test in different environments going to out to production.

Many items are referenced by an ID that is unique, or increment.

Need to know what are the expected results of your test.

If something you assume is incorrect, your tests will fail.

User not there

Items expired

Dates changed

GUI item changed or vanished

In unit testing, you can mock data to test with.

When testing a real system, your data can fluctuate

DB Refresh

Virtualized environments

User activity can change your data set

Date oriented things expire

Id’s increment

Using external or live data

(17)

Data Options

 Set our data manually each run.

DB Copy/refresh to return to a known state.

 Start from and return to a known state

CRUD only your data

 Get current data

Connect to the db to grab data.

Run UI automation to get data.

 Generate data

Use automation to generate a data set at run time

(18)

My Solution

 Data Generation Suite-

Can point to any client/environment.

Checks to see if my data is there, if it is it deletes it.

Then creates all data fresh, and sets state.

 A Smoke Test to be run by the Hudson server.

Checks all major functionality.

Checks each of the functional areas

Doesn’t validate what data it gets. (it fluctuates too much)

 A Regression Test that tests full functionality.

Data Generation Suite needs to be run first

Tests full functionality and validates data is correct.

 Fitnesse tests that check the services

Use the data selenium created.

Verify boundary conditions

Verify response code and format.

Verify errors

(19)

The end result

 All builds automatically are smoke tested for viability.

 Takes ~15 minutes to regression test a build in each environment

 Can change users, clients, environments, configuration.

 All tests don’t always pass in all environments, have to check test results.

 Can use Test Driven Development methodology

Create tests first

Code is good when they pass

 Relying heavily on automation

 Fast turnaround.

 High confidence level for code changes, new services

(20)

In progress

 Work on new framework

 Migrate to Selenium2 (mobile browser support)

 Fully implement PageObjects

 Use a VS config file

 Support multiple browsers

References

Related documents

Spectral transmittance of IR cut-off filters in Sinarback 54 camera; solid line is built-in IR cut-off filter in the fabricated camera; dashed line is combined transmittance of

El objetivo de este artículo es identificar y describir las representaciones de género católicas en torno a la participación de las mujeres en sociedades

This research is designed to answer the central question: “What is the role of conflict in determining consensus on quality in Wikipedia articles?” By combining a

a The population of apoptotic cells of SK-OV-3 PNPO-shRNA-expressing cells (shPNPO) and negative control cells (NC) was determined by flow cytometry. b Histogram shows the

As described in Section 1, credit card transaction data is extremely different from the rate of classes of data in classification; however, we constructed the VFDT without

“somewhat agree”, “agree” or “strongly agree” as a multiple night guest in a hotel to reuse their towel; 86.31% “somewhat agree”, “agree” or “strongly agree” as

Finally, a specific project or projects will be set up, focusing on development and verification of early innovative technical solutions on recycling of energy and material

Our assessment process provides guidance to operational- ize the model for assessing library usage in a specific software project. When assessing a real-world project, the sheer