fitnesse

30
© 2012 LogiGear Corporation. All Rights Reser FitNesse Authors: Nghia Pham 1

Upload: shad-roach

Post on 01-Jan-2016

46 views

Category:

Documents


3 download

DESCRIPTION

FitNesse. Authors: Nghia Pham. Agenda. FitNesse Fit and Slim How to write Test Cases Connect DataBase with Fit SSH with Slim. FitNesse – A brief intro. FitNesse – A brief intro. What is FitNesse ? A web server A wiki A tool for enhancing collaboration in software development - PowerPoint PPT Presentation

TRANSCRIPT

© 2012 LogiGear Corporation. All Rights Reserved

1

FitNesseFitNesse

Authors: Nghia Pham

© 2012 LogiGear Corporation. All Rights Reserved

2

Agenda

FitNesse Fit and Slim How to write Test Cases Connect DataBase with Fit SSH with Slim

© 2012 LogiGear Corporation. All Rights Reserved

3

FitNesse – A brief intro

© 2012 LogiGear Corporation. All Rights Reserved

4

FitNesse – A brief intro

What is FitNesse?A web serverA wikiA tool for enhancing collaboration in

software developmentA software testing tool

• Define Acceptance Tests (simple tables(input, output))

• It supports Java (native), .Net, C++ …• It provides a simple way to run tests (tables)

and suits

© 2012 LogiGear Corporation. All Rights Reserved

5

FitNesse – A brief intro

Fitnesse is notAn automation tool with interface

capturing abilityAn automation tool with web browser

driving ability

But there’re such tools that work with Fitnesse

© 2012 LogiGear Corporation. All Rights Reserved

6

FitNesse – A brief intro

Table-based approach for acceptance testing

• Starting from a user story, the customer enters in a table (spreadsheet) the expectations of the program’s behavior.

• At this point tables can be used as oracle. The customer can manually insert inputs in the System and compare outputs with expected results.

© 2012 LogiGear Corporation. All Rights Reserved

7

Fit and Slim

Fit Slim

No, we’re not talking about this kind of Fit and Slim

© 2012 LogiGear Corporation. All Rights Reserved

8

Fit and Slim

Fit (Framework for Integrated Test) andSlim (Simple List Invocation Method)are two different ways (test engines) to do automation testing with FitNesse

© 2012 LogiGear Corporation. All Rights Reserved

9

Fit and Slim

Fit Born with Fitnesse

Slim Developed later as an

alternative to Fit

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

Developers write “fixtures” to link the test cases with the Slim Executor

Fit compares these test cases with actual values returned by the system, and highlights the results with colors and annotations

All the HTML processing, comparisons, and colorizing are run on Fitnesse server

© 2012 LogiGear Corporation. All Rights Reserved

10

Fit and Slim

Fit Fixture code is run on the

system under test (SUT), so it depends on the system

Slim All the features are on the

FitNesse server, so test tables remain consistent regardless of the platform of the SUT

Lots of differences between implementations in Java, .NET, Python

No need to import fixture class, common syntax, common fixture types

Fit has not been developed for a while

Slim is in active development

© 2012 LogiGear Corporation. All Rights Reserved

11

How to…

How to…

It’s demo time

© 2012 LogiGear Corporation. All Rights Reserved

12

How to install Fitnesse

Software requirement:Oracle JDK for your platform from http://

www.oracle.com/technetwork/java/javase/downloads/index.html

Eclipse for Java EE from http://www.eclipse.org/downloads/

Latest fitnesse.jar from http://www.fitnesse.org/FrontPage.FitNesseDevelopment.DownLoad

© 2012 LogiGear Corporation. All Rights Reserved

13

How to run Fitnesse

Create a “StartFitnesse.bat” in the same folder with “fitnesse.jar”

Create its content using the syntax:java -jar [path]\fitnesse.jar -p port_number

Ex: java -jar d:\fitnesse.jar -p 9999

Double click the bat file to start Fitnesse server

Open a web browser and navigate to http://localhost:9999/

© 2012 LogiGear Corporation. All Rights Reserved

14

How to create a page

Every Fitnesse page must has a name inCamel-Case format.

Ex: TestPage, OneMorePage, LastOneHere

Create a root page (no parent): Put the page name in an existing page where you want to

create a link to it, prefix the name with a dot “.” Click the [?] next to the page name to create content for

the page. The page name above will become a link Create a child page:

Click [add child] link next to the parent page title and enter the child page name

Create a link for the page or it will become a lost page

© 2012 LogiGear Corporation. All Rights Reserved

15

How to create a table

Create a table in FitnesseThe first cell contains the table name Design the table in a spreadsheetOpen Edit mode of a pageCopy and paste the table hereClick “Spreadsheet to Fitnesse” buttonSave changes

© 2012 LogiGear Corporation. All Rights Reserved

16

How to create a Slim fixture

Create Slim fixture for Decision tableOpen Eclipse, create a new Java projectAdd a new package, give it any name you like Add a new class in the package. Its name must

be the same as the table you want to link toAdd methods for input and output columns

• Output method has the same name as its column. It returns the expected result.

• Input method has prefix “set” before its column name. It takes in the value of the column.

Set path to the “bin” folder of the project in the test page and import the package above

© 2012 LogiGear Corporation. All Rights Reserved

17

How to create a Slim fixture

© 2012 LogiGear Corporation. All Rights Reserved

18

How to use external library

To use an external library Add the library to the Java project (fixture

code). Import its classes and use however you like

Set the path to the external library in the test pages that require this library

It’s as simple as that

Demo Keyword-driven test with Selenium Web-Driver library

© 2012 LogiGear Corporation. All Rights Reserved

19

Connect Database with Fit

To use an external library Step 1: Create DataBase in FitFitNesseDemo page

Step 2: Edit content in DataBase page>MySql>SetUp>SuiteSetUp>TearDown>InterFaces

© 2012 LogiGear Corporation. All Rights Reserved

20

Connect Database with Fit

To use an external library Step 4: Create a new page in Interfaces

Step 5: Declare some variables in DatabaseVariables!define host {localhost}!define schema {automation}!define user {root}!define pass {root}

© 2012 LogiGear Corporation. All Rights Reserved

21

Connect Database with Fit

To use an external library Step 6: Create a new page “ConnectionDataBase” in

MySql

Step 7: Change properties in ConnectionDataBase page from Default to Test type

© 2012 LogiGear Corporation. All Rights Reserved

22

Connect Database with Fit

Step 8: Edit ConnectDataBase!*****> Import Interfaces in the SimpleSelect!include .FitFitNesseDemo.AdminPortal.InterFaces.GlobalVariables!include .FitFitNesseDemo.AdminPortal.InterFaces.LogInPage!include .FitFitNesseDemo.DataBase.InterFaces.DatabaseVariables *****!

!*****> Define to call multiple fixtures:|''add''|!-dbfit.MySqlTest-!|''as''|database||''add''|!-fitlibrary.spider.SpiderFixture!|''as''|spider|*****!

!*****> Connect to database!|Connect|${host}|${user}|${pass}|${schema}|*****!

© 2012 LogiGear Corporation. All Rights Reserved

23

Connect Database with Fit

Step 8: Edit ConnectDataBase!*****> Query to get username and password in database|''select''|database|!3 Simple Select |query| SELECT username FROM user WHERE role='${roleName}'||username?||>>account| |query| SELECT password from person where id =(SELECT person_id FROM

`user` WHERE role='${roleName}')||password?||>>password|*****!

!*****> Set username and password  |set|username|get symbol named|account||set|password|get symbol named|password|*****!

© 2012 LogiGear Corporation. All Rights Reserved

24

Connect Database with Fit

Step 8: Edit ConnectDataBase!*****> Query to get username and password in database|''select''|database|!3 Simple Select |query| SELECT username FROM user WHERE role='${roleName}'||username?||>>account| |query| SELECT password from person where id =(SELECT person_id FROM

`user` WHERE role='${roleName}')||password?||>>password|*****!

!*****> Set username and password  |set|username|get symbol named|account||set|password|get symbol named|password|*****!

© 2012 LogiGear Corporation. All Rights Reserved

25

SSH with Slim

To use an external library Step 1: Add “jsch.jar” and “remote-

api.jar” library to our lib folder.Step 2: Create SlimFitNesseDemo page

© 2012 LogiGear Corporation. All Rights Reserved

26

SSH with Slim

Step 3: Config in SlimFitNesseDemo page >Ssh

!path lib/*.jar

!define TEST_SYSTEM {slim} !define COLLAPSE_SETUP {true}

!define COLLAPSE_TEARDOWN {true}

Step 4: Create SlimFitNesseDemo page

© 2012 LogiGear Corporation. All Rights Reserved

27

SSH with Slim

Step 3: Config in SlimFitNesseDemo page|import|

|com.cisco.tcbu.automation.ssh|!*****> Execute a command by ssh

|Script|Ssh On Fitnesse|192.168.170.228||check|connect|root |true||check|exec|ls -la|0||check|exec|cd folder|1||check|exec|ls -a --color=never|0||$check=|exec|tail -30 ../var/log/messages.log||check|disconnect|false|**********!

© 2012 LogiGear Corporation. All Rights Reserved

28

SSH with Slim

Step 4: Run the test case

© 2012 LogiGear Corporation. All Rights Reserved

29

© 2012 LogiGear Corporation. All Rights Reserved

30

THANK YOU