Fitnesse Testing Framework

28
FitNesse On the Road to Success by ajit Koti

description

 

Transcript of Fitnesse Testing Framework

Page 1: Fitnesse Testing Framework

FitNesse

On the Road to Success

by ajit Koti

Page 2: Fitnesse Testing Framework

What we will cover today

What is FitNesse? Tradition Approach Quick introduction Quick Demo

How it works Different types of tables

Conclusion

Page 3: Fitnesse Testing Framework

Traditional Approaches for acceptance testing

Manual Acceptance testing. User exercises the system manually using his creativity.

Acceptance testing with “GUI Test Drivers” (at the GUI level). These tools help the developer do functional/acceptance testing through a user interface such as a native GUI or web interface. “Capture and Replay” Tools capture events (e.g. mouse, keyboard) in modifiable script.

Disadvantages: expensive, error prone,

not repeatable, …

Disadvantages: expensive, error prone,

not repeatable, …

Page 4: Fitnesse Testing Framework

Framework for Integrated Testing FitNesse, a wiki using Fit Defining Acceptance Tests, checking that “We are

building the right thing” Creating a feedback loop between customers,

testers and programmers

Provides a one-click test environment

Fit / FitNesse

Page 5: Fitnesse Testing Framework

What is FitNesse?

FitNesse is a software development collaboration tool Great software requires collaboration and communication.

FitNesse is a tool for enhancing collaboration in software development.

FitNesse enables customers, testers, and programmers to learn what their software should do, and to automatically compare that to what it actually does do. It compares customers' expectations to actual results.

It's an invaluable way to collaborate on complicated problems (and get them right) early in development

Page 6: Fitnesse Testing Framework

What is Fit?

The Framework for Integrated Test (Fit) is the most well-known implementation (open source framework) of the table-based acceptance testing approach.

Fit lets customers and analysts write “executable” acceptance tests using simple HTML tables.

Developers write “fixtures” to link the test cases with the actual system itself.

Fit compares these test cases, written using HTML tables, with actual values, returned by the system, and highlights the results with colors and annotations.

Page 7: Fitnesse Testing Framework

Now some Demos

Simple Calculator

Discount Calculator

Page 8: Fitnesse Testing Framework

What we will cover today

What is FitNesse?

How it works Using Fit Fit table Fixture Test Runner

Different types of tables Conclusion

Page 9: Fitnesse Testing Framework

Using Fit

Just two steps are required to automate user acceptance tests using Fit:

Express a test case in the form of a Fit table. Write the glue code, called a Fixture, that bridges

the test case and system under test.

That's it!

You are all set to execute the tests automatically for the rest of the application’s lifetime.

Page 10: Fitnesse Testing Framework

Fit table

A Fit table is a way of expressing the business logic using a simple HTML table.

Fit tables help developers better understand the requirements and are used as acceptance test cases.

Customers and Analysts create Fit tables using a tool like Word, Excel, or even a text editor

Page 11: Fitnesse Testing Framework

Fixture

A fixture is an interface between the test instrumentation (in our case, the Fit framework), test cases (Fit tables), and the system under test.

Fixtures are procedures/functions/classes usually written by developers.

In general, there is a one-to-one mapping between a Fit table and fixture.

Page 12: Fitnesse Testing Framework

Test Runner

The Test runner compares the customer-set expectations with the actual results and reports any errors by color-coding the table rows. 75572638Wigan

100 expected------------------- 93 actual

213538Dummy

93213538Chelsea

541622038Aston Villa

83523138Arsenal

rating()lostdrawnwonplayedteam name

sample.VerifyRating

“red for failures and green for passed tests”

Page 13: Fitnesse Testing Framework

How it works

The text is interpreted so it can trigger the fixtures that call the System-Under-Test (SUT)

Fit interprets the results and display Pass/Fail in each cell

Proper syntax is key Not so hard to learn… …after you get going

Page 14: Fitnesse Testing Framework

The Fit picture

User Story

Fit Table

Fixture

Customer/Analyst (i, o)

System

io’

Developer

o ≠ o’

Test Runner

Output Table

O = expected outputO’ = actual output

Page 15: Fitnesse Testing Framework

Fixture ClassPublic Class Calculator Public Number1 As Double Public Number2 As Double Private _oSUTCalculator As DemoSUT.SUTCalculator

Public Sub New() _oSUTCalculator = New DemoSUT.SUTCalculator End Sub

Public Function Product() As Double Return _oSUTCalculator.Multiply(Number1, Number2) End Function

End Class

System Under TestPublic Class SUTCalculator Public Function Multiply( _ ByVal firstNumber As Double, _ ByVal secondNumber As Double) _ As Double Return firstNumber * secondNumber End FunctionEnd Class

Table, Fit, and Fixture together

Fixture and SUT working together

Page 16: Fitnesse Testing Framework

What we will cover today

What is FitNesse? How it works

Different types of tables Decision Table Query table Script Table Table Table

Conclusion

Page 17: Fitnesse Testing Framework

Different styles of Tables

Test SystemFitSlim

Page 18: Fitnesse Testing Framework

Fit Tables ColumnFixture

This is the style you may end up using most: rows of data represent inputs and expected outputs.

RowFixture

This is good for testing queries that should return an exact set of values (order-independently)

.ActionFixture

This style allows you write a script that emulates a series of events (such as controls manipulated on a user interface).

Comment Tables

Sometimes you want a tablular comment that is not executed as a test.

Page 19: Fitnesse Testing Framework

The SLIM Test System

Slim (Simple List Invocation Method) is an alternative to Fit. Rather than running all the HTML processing, comparisons, and colorizing in the System Under Test (SUT), Slim keeps all that behavior on in FitNesse. What executes in the SUT is a very tiny kernel that implements the Slim Protocol. This protocol is a bare bones RPC system that allows FitNesse to call functions in the SUT.

Different table styles in Slim

Decision Table Query Table Subset Query Table Ordered query Table Script Table Table Table

Page 20: Fitnesse Testing Framework

Decision Table

Decision Tables are a common way to get test data into a System Under Test.

A Decision table has three parts One Title Row - Names the fixture to execute, optionally

includes constructor parameters One Heading Row - Names of columns, which map to

either setter methods or method calls (if they end in ?) Zero or more Data Rows - rows of data used to either

provide data into a system or data used to compare to values returned from the fixture

Page 21: Fitnesse Testing Framework

Query table

A Query table is a means of performing a single query and verifying the results.

They can pass parameters into the constructor of their fixture. They expect a method, query, which returns a List of a List of

a List of strings.

.

Page 22: Fitnesse Testing Framework

Script Table

Script tables are a convenient way to introduce code-like sequences into your tests.

They derive their design from Smalltalk keyword messages but other than that, they behave like other Slim tables:They are backed with a fixture

They have one or more method invocations, one per line. There are several keywords you can start a line with such as show and

check. The full method name is in parts, alternating with parameters passed in

to the backing fixture. The method name starts in cell 1 if the line does not start with one of a

small set of pre-defined keywords (check, reject, ...). Otherwise, it begins in cell 2.

Page 23: Fitnesse Testing Framework

Table Table

Page 24: Fitnesse Testing Framework

What we will cover today

What is FitNesse? How it works Different types of tables

Conclusion How to get help Q& A

Page 25: Fitnesse Testing Framework

Conclusions Manual acceptance testing is expensive, error prone and

not repeatable.

Fit/Fitnesse is a tool to write, organize and execute table-based tests.

Fit tables help to clarify “textual requirements”.

Fit tables “are requirements verifiable and executable”.

Fit is compatible with Junit.

The motivation of Fit/Fitnesse testing is demonstrating working functionalities while the motivation of Junit is finding faults

Page 26: Fitnesse Testing Framework

How to get help

Fitnesse on the web

To install FitNesse

WORKING WITH FITNESSE WIKI PAGES

VIDEO TUTORIALS

A great book “ Fit for Developing Software” with its samples

Page 27: Fitnesse Testing Framework

Q & A

Page 28: Fitnesse Testing Framework

Thank You