SlideShare uma empresa Scribd logo
1 de 36
Training
on
Database Unit Testing
with
DbFit
Conducted by
Md. Babul Mirdha
Senior Software Engineer
Leads Corporation Ltd
1
Part- I
What is dbFit?
• DbFit is a Poka-Yoke device for Database Development.
• DbFit is a set of FIT fixtures which enables FIT/FitNesse
tests to execute directly against a database.
• This enables developers to manipulate database
objects in a relational tabular form, making database
testing and management.
2
Features of DbFit
• Test Driven development for Database Development
• Integration testing, Regression testing for queries
and SQL statements
• Functional testing for stored procedures and
functions
• Automatic transaction control and various short-cuts
to make writing test scripts easier and more efficient
• Support for
– DB2, Oracle and SQL Server (java and .net versions)
– MySql 5 and Derby (only java).
3
Dbfit Picture (How DbFit works)
Fit Table
DbFit Fixtures
(i , o)
DataBase
i
o’
Db Developer
o ≠ o’
Test Runner
Output Table
i= input
o = expected output
o’ = actual output
User Story & Test Script
Using Wiki
Customer/
Analyst
4
Installing DbFit
• Install Java JRE 5 or later
• Install Microsoft's .NET Framework runtime 2 or later
• To use DbFit fixtures in your tests, download the
dbfit-dotnet-binaries package from
http://sourceforge.net/projects/dbfit.
• To install dbFit just unpack dbfitcomplete-XXX.zip
somewhere on your disk, and run startFitnesse.bat
(or startFitnesse.sh on Linux)
5
Working with Wiki
6
What is a Wiki?
A minimalist (simple) Content Management
System.
– Everyone can change every page.
– Changes are visible immediately.
– There are abbreviations for often used HTML
tags.
• Wiki will be used to write Test Script
Wikipedia …
7
WikiWord & WikiPage
• Wiki word is Pascal Case: an alternating pattern of upper and
lower case letters.
• A wiki word is a string of two more more capital letters with
lower case letters or numbers between them.
Word WikiWord?
BobMartin Yes
SalesReport1972 Yes
USAforEver No
Usa1776 No
RcM Yes
ItDoesNotMatter Yes• A wiki word helps to create & Link a Wiki Page
• A WikiWord like Text in a wiki page is considered as a page link.
8
Character Formatting
Format Name Syntax Remark
Comment #text Can also be used to comment-out markup
Italic ‘’text’’
Bold ‘’’text’’’
Style !style_(text) The style of text will be the CSS class <someStyle>
Strike-through --text--
"As-is"/escaping !-text -! Can also be used to insert HTML tags directly
"As-is" !<text>! Will escape HTML tags so they display in plain text.
Alias Link [[TEXT][PagePATH]] 9
Line & Block Formatting
Format Name Syntax Remark
Horizontal line ---- Thinnest
Note !note text
Headings
!1 largest heading text
!2 middle heading text
!3 smaller heading text
and so on up to !6
Centered !c text
Formatted "as
is"
{{{text}}} note: causes extra line afterward
"As-is"/escaping !-text-! Can also be used to insert HTML tags directly
Alias Link [[TEXT][PagePATH]]
10
Collapsible Block
Format Name Syntax Remark
Expanded
!* [title]
multi-line wiki text
*!
Collapsed !*> [title]
multi-line wiki text
*!
Invisible !*< [title]
multi-line wiki text
*!
useful for hidding define's, etc.
11
Links & References
Page links
Format Name Syntax Remark
from root
.RootPage[.ChildPage]
Sibling
SameLevelPage[.ChildPage]
child or
symbolic
>ChildPage[.ChildPage]
12
Writing Fit table using Wiki
!| RowFixtureTest |
|name |post code |
|John Smith |SW4 66Z |
|Michael Jordan | NE1 8AT |
Fig: Wiki Fig: Fit table
NB: The exclamation mark before the first cell in the table header tells FitNesse not to
convert it to a page link
13
Demo
Wiki Page
14
Working With Fixtures
15
What is DbFit Fixture?
• A fixture is an interface between the test
instrumentation (the Fit framework), test cases
(Fit tables), and the system under test.
• Fixtures are procedures/functions/classes.
• In general, there is a one-to-one mapping
between a Fit table and fixture.
DbFit Fixtures
DataBase
(System Under Test)
Test Runner
(Fit/Fitnesse)Test cases
16
Demo on Simple Example
!define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer,dotnet2fit.dll %p}
!define TEST_RUNNER {dotnet2Runner.exe}
!path dotnet2*.dll
!|dbfit.SqlServerTest|
!|Connect|pcsw188|sa|leads|TestDb|
!|Execute Procedure|ConcatenateStrings|
|firststring|secondstring|concatenated?|
|Hello|World|Hello World|
|Babu|Mirdha|Babu Mirdha|
17
Query Fixture
• Query tests lists of objects using SQL Query
results.
• Specify query as the first fixture parameter, after
the Query command.
• The second table row contains column names,
and all subsequent rows contain data for the
expected results.
!|query| SELECT AccountNo , AccountName, OpeningBalance FROM tb_Accounts|
|AccountNo|AccountName |OpeningBalance|
|1001 |Imtiaz Ahamed|5000.00 |
18
Ordered Query Fixture
• Query ignores row order by default. In flow mode, the Ordered Query command provides order
checking.
• This will fail because the order is wrong
|Ordered Query|SELECT n FROM ( SELECT 1 as n union select 2 union select 3 ) x |
|n|
|2|
|1|
|3|
• This will pass because the order is correct
|Ordered Query|SELECT n FROM ( SELECT 1 as n union select 2 union select 3 ) x|
|n|
|1|
|2|
|3|
Self Study
19
Use Query Fixrue, If your sp produces a ResultSet
!|query |sp_CurrentBalance '1001'|
|AccountNo|Name |Amount|
|1001| Imtiaz Ahamed |4000.00|
20
Fixture Symbol
• Symbols are global variables that can be accessed using a simple syntax.
• Symbols are stored in a static collection inside the Fixture class
• To store a value of an output column into a symbol named player, write
>>player into the cell.
• To read a symbol value, and store it into an input column, use <<player.
• Think of << and >> as arrows pointing the way.
|Query | select 'Babu' as Name|
|Name?|
|>>MyName|
|Query | select @MyName as Name|
|Name?|
|Babu|
21
Store Query Fixture
• Store Query reads out query results and stores them
into a Fixture symbol for later use.
• Specify the full query as the first argument and the
symbol name as the second argument (without >>).
• You can then use this stored result set as a parameter
of the Query command later:
!|Store Query|select n from ( select 1 as n union select 2 ) x|firsttable|
!|query|<<firsttable|
|n|
|1|
|2|
22
CompareStoredQueries Fixture
• CompareStoredQueries compares two previously stored query results
!|insert|testtbl|
|n|name|
|1|NAME1|
|3|NAME3|
|2|NAME2|
!|Store Query|select * from testtbl|fromtable|
!|Store Query|select n, dbo.concat('NAME',n) as name from ( select 1 as n
union select 3 union select 2) x|fromdual|
!|compare stored queries|fromtable|fromdual|
|name|n?|
Self Study
23
Insert Fixture
• Insert builds an insert command from the parameters in a data table (and
executes the insert once for each row of the table).
• The view or table name is given as the first fixture parameter.
• The second row contains column names, and all subsequent rows contain
data to be inserted.
|Insert|Test_DBFit|
|name|luckyNumber|
|pera|1|
|nuja|2|
|nnn|3|
|Query|Select * from Test_DBFit|
|name|lucky Number|
|pera|1|
|nuja|2| |nnn|3|
24
Storing auto-generated values
!3 Use ? to mark columns that should return values
!|Insert|users|
|username|name|userid?|
|pera|Petar Detlic|>>peraid|
|Mika|Mitar Miric|>>mikaid|
|Zeka|Dusko Dugousko|>>zeka|
|DevNull|null|>>nllid|
!3 Confirm that IDs are the same as in the database
!|Ordered Query|Select * from users|
|username|name|userid|
|pera|Petar Detlic|<<peraid|
|Mika|Mitar Miric|<<mikaid|
|Zeka|Dusko Dugousko|<<zekaid|
|DevNull|null|<<nllid|
!3 Stored values can be used in queries directly
|Query|Select * from users where userid=@zekaid|
|username|name|userid|
|Zeka|Dusko Dugousko|<<zekaid|
25
Update
• Update allows you to quickly script data
updates.
• Columns ending with = are used to update
records (cell specifies new data value).
• Columns without = on the end are used to
select rows (cell specifies expected column
value for the select part of update command).
Self Study
26
Update
This example updates the username column where the name matches arthur dent .
|insert|users|
|name|username|
|arthur dent|adent|
|ford prefect|fpref|
|zaphod beeblebrox|zaphod|
|update|users|
|username=|name|
|adent2|arthur dent|
|query|select * from users|
|name|username|
|arthur dent|adent2|
|ford prefect|fpref|
|zaphod beeblebrox|zaphod|
27
Execute Fixture
• Execute executes any SQL statement.
• You can use query parameters in the DB-specific syntax (eg. @paramname for
SQLServer and MySQL, and :paramname for Oracle).
!3 to execute statements, use the 'execute' command
!|Execute|Insert into Test_DBFit values (‘Aftab Ahmed',80)|
|Set parameter|name|Imtiaz Ahmed|
|Execute|Insert into Test_DBFit values (@name,10)|
!|Query|Select * from Test_DBFit|
|Name|Lucky Number|
|Darth Maul|10|
|Obi Wan|80|
28
Execute Fixture (Cont)
!|Insert|Users|
|username|name|UserId?|
|pete|Peter Pan|>>user1|
|mike|Michael Jordan|>>user2|
!|Execute| Update Users set name='Michael Jackson' where userid=@user2|
!|Query|Select * from users|
|userid|username?|name?|
|<<user1|pete|Peter Pan|
|<<user2|mike|Michael Jackson|
29
ExecuteProcedure
• It executes a stored procedure or function for each row of
data table, binding input/output parameters to columns.
• !3 execute procedure allows multiple parameters, with blanks in names
• !|Execute Procedure|ConcatenateStrings|
• |first string|second string|concatenated?|
• |Hello|World|Hello World|
• |Word|Prefect|Word Prefect|
• !3 IN/OUT params need to be specified twice
• |execute procedure|Multiply|
• |factor|val|val?|
• |5|10|50|
30
ExecuteProcedure (Cont)
• !3 If there are no parameters, Execute
Procedure needs just one row
• !|Execute Procedure|MakeUser|
• |query|select * from users|
• |name|username|
• |user1|fromproc|
31
ExecuteProcedure (Cont)
• !3 Stored functions are treated like procedures - just put ? in the result
column header
• !|Execute Procedure|ConcatenateF|
• |first string|second string|?|
• |Hello|World|Hello World|
• |Ford|Prefect|Ford Prefect|
• !3 ? does not have to appear on the end (although it is a good practice to
put it there)
• !|Execute Procedure|ConcatenateF|
• |second string|?|first string|
• |World|Hello World|Hello|
• |Prefect|Ford Prefect|Ford|
32
Inspect Fixture
• Inspect extracts meta-data information from the database, and print it out
in a form which can be easily converted into a test.
• It can work in three modes: Query, Table or Procedure.
!3 Inspect Procedure prints procedure arguments to be used for Execute procedure
!|Inspect Procedure|ConcatenateStrings|
!3 Inspect Table prints table/view columns to be used for Insert/Update/Query Procedure
!|Inspect Table|users|
!3 Inspect query prints columns and data
|Insert|users|
|name|username|
|david haselhoff|dhoff|
|arthur dent|adent|
!|Inspect query|select * from users|
33
References
• Test Driven Database Development With DbFit -
Marisa Seal, Gojko Adzic
• Test Driven .NET Development with FitNesse
-Gojko Adzic
• http://fitnesse.info/dbfit
• http://www.methodsandtools.com/tools/tools.p
hp?fitnesse
• http://working-
thought.blogspot.com/2008/10/connecting-to-
oracle-grid-with-dbfit.html
34
Thank You!
35
Q & A
36

Mais conteúdo relacionado

Mais procurados

Introduction to performance testing
Introduction to performance testingIntroduction to performance testing
Introduction to performance testingTharinda Liyanage
 
What you have to know about Certified Kubernetes Administrator (CKA)
What you have to know about Certified Kubernetes Administrator (CKA)What you have to know about Certified Kubernetes Administrator (CKA)
What you have to know about Certified Kubernetes Administrator (CKA)Opsta
 
JCConf 2021 - Java17: The Next LTS
JCConf 2021 - Java17: The Next LTSJCConf 2021 - Java17: The Next LTS
JCConf 2021 - Java17: The Next LTSJoseph Kuo
 
JSP 프로그래밍 #02 서블릿과 JSP 시작하기
JSP 프로그래밍 #02 서블릿과 JSP 시작하기JSP 프로그래밍 #02 서블릿과 JSP 시작하기
JSP 프로그래밍 #02 서블릿과 JSP 시작하기Myungjin Lee
 
Gatling overview
Gatling overviewGatling overview
Gatling overviewViral Jain
 
Mainframe DevOps Using Zowe Open Source
Mainframe DevOps Using Zowe Open SourceMainframe DevOps Using Zowe Open Source
Mainframe DevOps Using Zowe Open SourceDevOps.com
 
Transform Software Testing and Quality with the Neotys-Inflectra Platform
Transform Software Testing and Quality with the Neotys-Inflectra PlatformTransform Software Testing and Quality with the Neotys-Inflectra Platform
Transform Software Testing and Quality with the Neotys-Inflectra PlatformInflectra
 
Oracle APEX India Office Hours - Dashboard Cards Using OJT & UT
Oracle APEX India Office Hours - Dashboard Cards Using OJT & UTOracle APEX India Office Hours - Dashboard Cards Using OJT & UT
Oracle APEX India Office Hours - Dashboard Cards Using OJT & UTMehul Pandya
 
Load testing using_neoload by kc
Load testing using_neoload by kcLoad testing using_neoload by kc
Load testing using_neoload by kckrishna chaitanya
 
JMeter vs LoadRunner | Edureka
JMeter vs LoadRunner | EdurekaJMeter vs LoadRunner | Edureka
JMeter vs LoadRunner | EdurekaEdureka!
 
DevOps on AWS - Building Systems to Deliver Faster
DevOps on AWS - Building Systems to Deliver FasterDevOps on AWS - Building Systems to Deliver Faster
DevOps on AWS - Building Systems to Deliver FasterAmazon Web Services
 
BlazeMeter Presents at the High Performance Drupal Meetup
BlazeMeter Presents at the High Performance Drupal MeetupBlazeMeter Presents at the High Performance Drupal Meetup
BlazeMeter Presents at the High Performance Drupal MeetupBlazeMeter
 
Khaleel Devops Resume (2)
Khaleel Devops Resume (2)Khaleel Devops Resume (2)
Khaleel Devops Resume (2)khaleel a
 
Hardware/Software Integration Testing
Hardware/Software Integration TestingHardware/Software Integration Testing
Hardware/Software Integration TestingJohan Hoberg
 
왕초보를 위한 도커 사용법
왕초보를 위한 도커 사용법왕초보를 위한 도커 사용법
왕초보를 위한 도커 사용법GeunCheolYeom
 
Azure functions
Azure functionsAzure functions
Azure functionsvivek p s
 
Pros & cons of svelte
Pros & cons of sveltePros & cons of svelte
Pros & cons of svelteElenorWisozk
 

Mais procurados (20)

Event-sourced architectures with Akka
Event-sourced architectures with AkkaEvent-sourced architectures with Akka
Event-sourced architectures with Akka
 
Introduction to performance testing
Introduction to performance testingIntroduction to performance testing
Introduction to performance testing
 
What you have to know about Certified Kubernetes Administrator (CKA)
What you have to know about Certified Kubernetes Administrator (CKA)What you have to know about Certified Kubernetes Administrator (CKA)
What you have to know about Certified Kubernetes Administrator (CKA)
 
JCConf 2021 - Java17: The Next LTS
JCConf 2021 - Java17: The Next LTSJCConf 2021 - Java17: The Next LTS
JCConf 2021 - Java17: The Next LTS
 
JSP 프로그래밍 #02 서블릿과 JSP 시작하기
JSP 프로그래밍 #02 서블릿과 JSP 시작하기JSP 프로그래밍 #02 서블릿과 JSP 시작하기
JSP 프로그래밍 #02 서블릿과 JSP 시작하기
 
Gatling overview
Gatling overviewGatling overview
Gatling overview
 
Mainframe DevOps Using Zowe Open Source
Mainframe DevOps Using Zowe Open SourceMainframe DevOps Using Zowe Open Source
Mainframe DevOps Using Zowe Open Source
 
J Meter Intro
J Meter IntroJ Meter Intro
J Meter Intro
 
Load testing with J meter
Load testing with J meterLoad testing with J meter
Load testing with J meter
 
Transform Software Testing and Quality with the Neotys-Inflectra Platform
Transform Software Testing and Quality with the Neotys-Inflectra PlatformTransform Software Testing and Quality with the Neotys-Inflectra Platform
Transform Software Testing and Quality with the Neotys-Inflectra Platform
 
Oracle APEX India Office Hours - Dashboard Cards Using OJT & UT
Oracle APEX India Office Hours - Dashboard Cards Using OJT & UTOracle APEX India Office Hours - Dashboard Cards Using OJT & UT
Oracle APEX India Office Hours - Dashboard Cards Using OJT & UT
 
Load testing using_neoload by kc
Load testing using_neoload by kcLoad testing using_neoload by kc
Load testing using_neoload by kc
 
JMeter vs LoadRunner | Edureka
JMeter vs LoadRunner | EdurekaJMeter vs LoadRunner | Edureka
JMeter vs LoadRunner | Edureka
 
DevOps on AWS - Building Systems to Deliver Faster
DevOps on AWS - Building Systems to Deliver FasterDevOps on AWS - Building Systems to Deliver Faster
DevOps on AWS - Building Systems to Deliver Faster
 
BlazeMeter Presents at the High Performance Drupal Meetup
BlazeMeter Presents at the High Performance Drupal MeetupBlazeMeter Presents at the High Performance Drupal Meetup
BlazeMeter Presents at the High Performance Drupal Meetup
 
Khaleel Devops Resume (2)
Khaleel Devops Resume (2)Khaleel Devops Resume (2)
Khaleel Devops Resume (2)
 
Hardware/Software Integration Testing
Hardware/Software Integration TestingHardware/Software Integration Testing
Hardware/Software Integration Testing
 
왕초보를 위한 도커 사용법
왕초보를 위한 도커 사용법왕초보를 위한 도커 사용법
왕초보를 위한 도커 사용법
 
Azure functions
Azure functionsAzure functions
Azure functions
 
Pros & cons of svelte
Pros & cons of sveltePros & cons of svelte
Pros & cons of svelte
 

Destaque

Test-Driven Development with DbFit and Oracle database, BGOUG Conference, 201...
Test-Driven Development with DbFit and Oracle database, BGOUG Conference, 201...Test-Driven Development with DbFit and Oracle database, BGOUG Conference, 201...
Test-Driven Development with DbFit and Oracle database, BGOUG Conference, 201...Yavor Nikolov
 
Hands on training on DbFit Part-II
Hands on training on DbFit Part-IIHands on training on DbFit Part-II
Hands on training on DbFit Part-IIBabul Mirdha
 
Fitnesse Testing Framework
Fitnesse Testing Framework Fitnesse Testing Framework
Fitnesse Testing Framework Ajit Koti
 
Effective Test Driven Database Development
Effective Test Driven Database DevelopmentEffective Test Driven Database Development
Effective Test Driven Database Developmentelliando dias
 
見守りサービスMiimaミーマ 資料
見守りサービスMiimaミーマ 資料見守りサービスMiimaミーマ 資料
見守りサービスMiimaミーマ 資料kaisya_account
 
Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)Peter Kofler
 
Testing regression
Testing regressionTesting regression
Testing regressionRichie Lee
 
Open Source BI Overview
Open Source BI Overview Open Source BI Overview
Open Source BI Overview Alex Meadows
 
Trivadis TechEvent 2016 A few thoughts on the subject Continuous integration ...
Trivadis TechEvent 2016 A few thoughts on the subject Continuous integration ...Trivadis TechEvent 2016 A few thoughts on the subject Continuous integration ...
Trivadis TechEvent 2016 A few thoughts on the subject Continuous integration ...Trivadis
 
A data driven etl test framework sqlsat madison
A data driven etl test framework sqlsat madisonA data driven etl test framework sqlsat madison
A data driven etl test framework sqlsat madisonTerry Bunio
 
Lynn Winterboer : Test automation
Lynn Winterboer : Test automation Lynn Winterboer : Test automation
Lynn Winterboer : Test automation AgileDenver
 
Agile Methods and Data Warehousing (2016 update)
Agile Methods and Data Warehousing (2016 update)Agile Methods and Data Warehousing (2016 update)
Agile Methods and Data Warehousing (2016 update)Kent Graziano
 
TDD - Test Driven Dvelopment | Test First Design
TDD -  Test Driven Dvelopment | Test First DesignTDD -  Test Driven Dvelopment | Test First Design
TDD - Test Driven Dvelopment | Test First DesignQuang Nguyễn Bá
 
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...RTTS
 
ACC - конструируем тест-план методом Google
ACC - конструируем тест-план методом GoogleACC - конструируем тест-план методом Google
ACC - конструируем тест-план методом GoogleSQALab
 
Testing Big Data: Automated Testing of Hadoop with QuerySurge
Testing Big Data: Automated  Testing of Hadoop with QuerySurgeTesting Big Data: Automated  Testing of Hadoop with QuerySurge
Testing Big Data: Automated Testing of Hadoop with QuerySurgeRTTS
 
What is a Data Warehouse and How Do I Test It?
What is a Data Warehouse and How Do I Test It?What is a Data Warehouse and How Do I Test It?
What is a Data Warehouse and How Do I Test It?RTTS
 

Destaque (19)

Test-Driven Development with DbFit and Oracle database, BGOUG Conference, 201...
Test-Driven Development with DbFit and Oracle database, BGOUG Conference, 201...Test-Driven Development with DbFit and Oracle database, BGOUG Conference, 201...
Test-Driven Development with DbFit and Oracle database, BGOUG Conference, 201...
 
Hands on training on DbFit Part-II
Hands on training on DbFit Part-IIHands on training on DbFit Part-II
Hands on training on DbFit Part-II
 
Fitnesse Testing Framework
Fitnesse Testing Framework Fitnesse Testing Framework
Fitnesse Testing Framework
 
Effective Test Driven Database Development
Effective Test Driven Database DevelopmentEffective Test Driven Database Development
Effective Test Driven Database Development
 
見守りサービスMiimaミーマ 資料
見守りサービスMiimaミーマ 資料見守りサービスMiimaミーマ 資料
見守りサービスMiimaミーマ 資料
 
Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)
 
Testing regression
Testing regressionTesting regression
Testing regression
 
Open Source BI Overview
Open Source BI Overview Open Source BI Overview
Open Source BI Overview
 
Trivadis TechEvent 2016 A few thoughts on the subject Continuous integration ...
Trivadis TechEvent 2016 A few thoughts on the subject Continuous integration ...Trivadis TechEvent 2016 A few thoughts on the subject Continuous integration ...
Trivadis TechEvent 2016 A few thoughts on the subject Continuous integration ...
 
Sigist Presentation 091208 V2.0
Sigist Presentation 091208 V2.0Sigist Presentation 091208 V2.0
Sigist Presentation 091208 V2.0
 
Agile WTF
Agile WTFAgile WTF
Agile WTF
 
A data driven etl test framework sqlsat madison
A data driven etl test framework sqlsat madisonA data driven etl test framework sqlsat madison
A data driven etl test framework sqlsat madison
 
Lynn Winterboer : Test automation
Lynn Winterboer : Test automation Lynn Winterboer : Test automation
Lynn Winterboer : Test automation
 
Agile Methods and Data Warehousing (2016 update)
Agile Methods and Data Warehousing (2016 update)Agile Methods and Data Warehousing (2016 update)
Agile Methods and Data Warehousing (2016 update)
 
TDD - Test Driven Dvelopment | Test First Design
TDD -  Test Driven Dvelopment | Test First DesignTDD -  Test Driven Dvelopment | Test First Design
TDD - Test Driven Dvelopment | Test First Design
 
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...
 
ACC - конструируем тест-план методом Google
ACC - конструируем тест-план методом GoogleACC - конструируем тест-план методом Google
ACC - конструируем тест-план методом Google
 
Testing Big Data: Automated Testing of Hadoop with QuerySurge
Testing Big Data: Automated  Testing of Hadoop with QuerySurgeTesting Big Data: Automated  Testing of Hadoop with QuerySurge
Testing Big Data: Automated Testing of Hadoop with QuerySurge
 
What is a Data Warehouse and How Do I Test It?
What is a Data Warehouse and How Do I Test It?What is a Data Warehouse and How Do I Test It?
What is a Data Warehouse and How Do I Test It?
 

Semelhante a Hands on training on DbFit Part-I

Dynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data MergeDynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data MergeClay Helberg
 
Optimizing MySQL Queries
Optimizing MySQL QueriesOptimizing MySQL Queries
Optimizing MySQL QueriesAchievers Tech
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionMazenetsolution
 
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...dotNet Miami
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsRichie Rump
 
Rails Tips and Best Practices
Rails Tips and Best PracticesRails Tips and Best Practices
Rails Tips and Best PracticesDavid Keener
 
Implementing Tables and Views.pptx
Implementing Tables and Views.pptxImplementing Tables and Views.pptx
Implementing Tables and Views.pptxLuisManuelUrbinaAmad
 
nGram full text search (by 이성욱)
nGram full text search (by 이성욱)nGram full text search (by 이성욱)
nGram full text search (by 이성욱)I Goo Lee.
 
Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overviewbwullems
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksMYXPLAIN
 
Sample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docxSample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docxtodd331
 
Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012Brij Mishra
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database DeploymentsMike Willbanks
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsTeamstudio
 
U-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for DevelopersU-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for DevelopersMichael Rys
 

Semelhante a Hands on training on DbFit Part-I (20)

Scripting robot
Scripting robotScripting robot
Scripting robot
 
Dynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data MergeDynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data Merge
 
Optimizing MySQL Queries
Optimizing MySQL QueriesOptimizing MySQL Queries
Optimizing MySQL Queries
 
Module02
Module02Module02
Module02
 
Database programming
Database programmingDatabase programming
Database programming
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet Solution
 
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic Unicorns
 
Rails Tips and Best Practices
Rails Tips and Best PracticesRails Tips and Best Practices
Rails Tips and Best Practices
 
embedded C.pptx
embedded C.pptxembedded C.pptx
embedded C.pptx
 
Implementing Tables and Views.pptx
Implementing Tables and Views.pptxImplementing Tables and Views.pptx
Implementing Tables and Views.pptx
 
nGram full text search (by 이성욱)
nGram full text search (by 이성욱)nGram full text search (by 이성욱)
nGram full text search (by 이성욱)
 
Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overview
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New Tricks
 
Sample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docxSample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docx
 
Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational Controls
 
ASP.NET 4.0 Demo
ASP.NET 4.0 DemoASP.NET 4.0 Demo
ASP.NET 4.0 Demo
 
U-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for DevelopersU-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for Developers
 

Mais de Babul Mirdha

Water Transport Safety
Water Transport SafetyWater Transport Safety
Water Transport SafetyBabul Mirdha
 
iOS App Development with Storyboard
iOS App Development with StoryboardiOS App Development with Storyboard
iOS App Development with StoryboardBabul Mirdha
 
Objective-C with respect to C# and Java
Objective-C with respect to C# and JavaObjective-C with respect to C# and Java
Objective-C with respect to C# and JavaBabul Mirdha
 
An Objective-C Primer
An Objective-C PrimerAn Objective-C Primer
An Objective-C PrimerBabul Mirdha
 
Startup to be iOS developer
Startup to be iOS developerStartup to be iOS developer
Startup to be iOS developerBabul Mirdha
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Babul Mirdha
 

Mais de Babul Mirdha (6)

Water Transport Safety
Water Transport SafetyWater Transport Safety
Water Transport Safety
 
iOS App Development with Storyboard
iOS App Development with StoryboardiOS App Development with Storyboard
iOS App Development with Storyboard
 
Objective-C with respect to C# and Java
Objective-C with respect to C# and JavaObjective-C with respect to C# and Java
Objective-C with respect to C# and Java
 
An Objective-C Primer
An Objective-C PrimerAn Objective-C Primer
An Objective-C Primer
 
Startup to be iOS developer
Startup to be iOS developerStartup to be iOS developer
Startup to be iOS developer
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
 

Hands on training on DbFit Part-I

  • 1. Training on Database Unit Testing with DbFit Conducted by Md. Babul Mirdha Senior Software Engineer Leads Corporation Ltd 1 Part- I
  • 2. What is dbFit? • DbFit is a Poka-Yoke device for Database Development. • DbFit is a set of FIT fixtures which enables FIT/FitNesse tests to execute directly against a database. • This enables developers to manipulate database objects in a relational tabular form, making database testing and management. 2
  • 3. Features of DbFit • Test Driven development for Database Development • Integration testing, Regression testing for queries and SQL statements • Functional testing for stored procedures and functions • Automatic transaction control and various short-cuts to make writing test scripts easier and more efficient • Support for – DB2, Oracle and SQL Server (java and .net versions) – MySql 5 and Derby (only java). 3
  • 4. Dbfit Picture (How DbFit works) Fit Table DbFit Fixtures (i , o) DataBase i o’ Db Developer o ≠ o’ Test Runner Output Table i= input o = expected output o’ = actual output User Story & Test Script Using Wiki Customer/ Analyst 4
  • 5. Installing DbFit • Install Java JRE 5 or later • Install Microsoft's .NET Framework runtime 2 or later • To use DbFit fixtures in your tests, download the dbfit-dotnet-binaries package from http://sourceforge.net/projects/dbfit. • To install dbFit just unpack dbfitcomplete-XXX.zip somewhere on your disk, and run startFitnesse.bat (or startFitnesse.sh on Linux) 5
  • 7. What is a Wiki? A minimalist (simple) Content Management System. – Everyone can change every page. – Changes are visible immediately. – There are abbreviations for often used HTML tags. • Wiki will be used to write Test Script Wikipedia … 7
  • 8. WikiWord & WikiPage • Wiki word is Pascal Case: an alternating pattern of upper and lower case letters. • A wiki word is a string of two more more capital letters with lower case letters or numbers between them. Word WikiWord? BobMartin Yes SalesReport1972 Yes USAforEver No Usa1776 No RcM Yes ItDoesNotMatter Yes• A wiki word helps to create & Link a Wiki Page • A WikiWord like Text in a wiki page is considered as a page link. 8
  • 9. Character Formatting Format Name Syntax Remark Comment #text Can also be used to comment-out markup Italic ‘’text’’ Bold ‘’’text’’’ Style !style_(text) The style of text will be the CSS class <someStyle> Strike-through --text-- "As-is"/escaping !-text -! Can also be used to insert HTML tags directly "As-is" !<text>! Will escape HTML tags so they display in plain text. Alias Link [[TEXT][PagePATH]] 9
  • 10. Line & Block Formatting Format Name Syntax Remark Horizontal line ---- Thinnest Note !note text Headings !1 largest heading text !2 middle heading text !3 smaller heading text and so on up to !6 Centered !c text Formatted "as is" {{{text}}} note: causes extra line afterward "As-is"/escaping !-text-! Can also be used to insert HTML tags directly Alias Link [[TEXT][PagePATH]] 10
  • 11. Collapsible Block Format Name Syntax Remark Expanded !* [title] multi-line wiki text *! Collapsed !*> [title] multi-line wiki text *! Invisible !*< [title] multi-line wiki text *! useful for hidding define's, etc. 11
  • 12. Links & References Page links Format Name Syntax Remark from root .RootPage[.ChildPage] Sibling SameLevelPage[.ChildPage] child or symbolic >ChildPage[.ChildPage] 12
  • 13. Writing Fit table using Wiki !| RowFixtureTest | |name |post code | |John Smith |SW4 66Z | |Michael Jordan | NE1 8AT | Fig: Wiki Fig: Fit table NB: The exclamation mark before the first cell in the table header tells FitNesse not to convert it to a page link 13
  • 16. What is DbFit Fixture? • A fixture is an interface between the test instrumentation (the Fit framework), test cases (Fit tables), and the system under test. • Fixtures are procedures/functions/classes. • In general, there is a one-to-one mapping between a Fit table and fixture. DbFit Fixtures DataBase (System Under Test) Test Runner (Fit/Fitnesse)Test cases 16
  • 17. Demo on Simple Example !define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer,dotnet2fit.dll %p} !define TEST_RUNNER {dotnet2Runner.exe} !path dotnet2*.dll !|dbfit.SqlServerTest| !|Connect|pcsw188|sa|leads|TestDb| !|Execute Procedure|ConcatenateStrings| |firststring|secondstring|concatenated?| |Hello|World|Hello World| |Babu|Mirdha|Babu Mirdha| 17
  • 18. Query Fixture • Query tests lists of objects using SQL Query results. • Specify query as the first fixture parameter, after the Query command. • The second table row contains column names, and all subsequent rows contain data for the expected results. !|query| SELECT AccountNo , AccountName, OpeningBalance FROM tb_Accounts| |AccountNo|AccountName |OpeningBalance| |1001 |Imtiaz Ahamed|5000.00 | 18
  • 19. Ordered Query Fixture • Query ignores row order by default. In flow mode, the Ordered Query command provides order checking. • This will fail because the order is wrong |Ordered Query|SELECT n FROM ( SELECT 1 as n union select 2 union select 3 ) x | |n| |2| |1| |3| • This will pass because the order is correct |Ordered Query|SELECT n FROM ( SELECT 1 as n union select 2 union select 3 ) x| |n| |1| |2| |3| Self Study 19
  • 20. Use Query Fixrue, If your sp produces a ResultSet !|query |sp_CurrentBalance '1001'| |AccountNo|Name |Amount| |1001| Imtiaz Ahamed |4000.00| 20
  • 21. Fixture Symbol • Symbols are global variables that can be accessed using a simple syntax. • Symbols are stored in a static collection inside the Fixture class • To store a value of an output column into a symbol named player, write >>player into the cell. • To read a symbol value, and store it into an input column, use <<player. • Think of << and >> as arrows pointing the way. |Query | select 'Babu' as Name| |Name?| |>>MyName| |Query | select @MyName as Name| |Name?| |Babu| 21
  • 22. Store Query Fixture • Store Query reads out query results and stores them into a Fixture symbol for later use. • Specify the full query as the first argument and the symbol name as the second argument (without >>). • You can then use this stored result set as a parameter of the Query command later: !|Store Query|select n from ( select 1 as n union select 2 ) x|firsttable| !|query|<<firsttable| |n| |1| |2| 22
  • 23. CompareStoredQueries Fixture • CompareStoredQueries compares two previously stored query results !|insert|testtbl| |n|name| |1|NAME1| |3|NAME3| |2|NAME2| !|Store Query|select * from testtbl|fromtable| !|Store Query|select n, dbo.concat('NAME',n) as name from ( select 1 as n union select 3 union select 2) x|fromdual| !|compare stored queries|fromtable|fromdual| |name|n?| Self Study 23
  • 24. Insert Fixture • Insert builds an insert command from the parameters in a data table (and executes the insert once for each row of the table). • The view or table name is given as the first fixture parameter. • The second row contains column names, and all subsequent rows contain data to be inserted. |Insert|Test_DBFit| |name|luckyNumber| |pera|1| |nuja|2| |nnn|3| |Query|Select * from Test_DBFit| |name|lucky Number| |pera|1| |nuja|2| |nnn|3| 24
  • 25. Storing auto-generated values !3 Use ? to mark columns that should return values !|Insert|users| |username|name|userid?| |pera|Petar Detlic|>>peraid| |Mika|Mitar Miric|>>mikaid| |Zeka|Dusko Dugousko|>>zeka| |DevNull|null|>>nllid| !3 Confirm that IDs are the same as in the database !|Ordered Query|Select * from users| |username|name|userid| |pera|Petar Detlic|<<peraid| |Mika|Mitar Miric|<<mikaid| |Zeka|Dusko Dugousko|<<zekaid| |DevNull|null|<<nllid| !3 Stored values can be used in queries directly |Query|Select * from users where userid=@zekaid| |username|name|userid| |Zeka|Dusko Dugousko|<<zekaid| 25
  • 26. Update • Update allows you to quickly script data updates. • Columns ending with = are used to update records (cell specifies new data value). • Columns without = on the end are used to select rows (cell specifies expected column value for the select part of update command). Self Study 26
  • 27. Update This example updates the username column where the name matches arthur dent . |insert|users| |name|username| |arthur dent|adent| |ford prefect|fpref| |zaphod beeblebrox|zaphod| |update|users| |username=|name| |adent2|arthur dent| |query|select * from users| |name|username| |arthur dent|adent2| |ford prefect|fpref| |zaphod beeblebrox|zaphod| 27
  • 28. Execute Fixture • Execute executes any SQL statement. • You can use query parameters in the DB-specific syntax (eg. @paramname for SQLServer and MySQL, and :paramname for Oracle). !3 to execute statements, use the 'execute' command !|Execute|Insert into Test_DBFit values (‘Aftab Ahmed',80)| |Set parameter|name|Imtiaz Ahmed| |Execute|Insert into Test_DBFit values (@name,10)| !|Query|Select * from Test_DBFit| |Name|Lucky Number| |Darth Maul|10| |Obi Wan|80| 28
  • 29. Execute Fixture (Cont) !|Insert|Users| |username|name|UserId?| |pete|Peter Pan|>>user1| |mike|Michael Jordan|>>user2| !|Execute| Update Users set name='Michael Jackson' where userid=@user2| !|Query|Select * from users| |userid|username?|name?| |<<user1|pete|Peter Pan| |<<user2|mike|Michael Jackson| 29
  • 30. ExecuteProcedure • It executes a stored procedure or function for each row of data table, binding input/output parameters to columns. • !3 execute procedure allows multiple parameters, with blanks in names • !|Execute Procedure|ConcatenateStrings| • |first string|second string|concatenated?| • |Hello|World|Hello World| • |Word|Prefect|Word Prefect| • !3 IN/OUT params need to be specified twice • |execute procedure|Multiply| • |factor|val|val?| • |5|10|50| 30
  • 31. ExecuteProcedure (Cont) • !3 If there are no parameters, Execute Procedure needs just one row • !|Execute Procedure|MakeUser| • |query|select * from users| • |name|username| • |user1|fromproc| 31
  • 32. ExecuteProcedure (Cont) • !3 Stored functions are treated like procedures - just put ? in the result column header • !|Execute Procedure|ConcatenateF| • |first string|second string|?| • |Hello|World|Hello World| • |Ford|Prefect|Ford Prefect| • !3 ? does not have to appear on the end (although it is a good practice to put it there) • !|Execute Procedure|ConcatenateF| • |second string|?|first string| • |World|Hello World|Hello| • |Prefect|Ford Prefect|Ford| 32
  • 33. Inspect Fixture • Inspect extracts meta-data information from the database, and print it out in a form which can be easily converted into a test. • It can work in three modes: Query, Table or Procedure. !3 Inspect Procedure prints procedure arguments to be used for Execute procedure !|Inspect Procedure|ConcatenateStrings| !3 Inspect Table prints table/view columns to be used for Insert/Update/Query Procedure !|Inspect Table|users| !3 Inspect query prints columns and data |Insert|users| |name|username| |david haselhoff|dhoff| |arthur dent|adent| !|Inspect query|select * from users| 33
  • 34. References • Test Driven Database Development With DbFit - Marisa Seal, Gojko Adzic • Test Driven .NET Development with FitNesse -Gojko Adzic • http://fitnesse.info/dbfit • http://www.methodsandtools.com/tools/tools.p hp?fitnesse • http://working- thought.blogspot.com/2008/10/connecting-to- oracle-grid-with-dbfit.html 34

Notas do Editor

  1. Create PROCEDURE [dbo].[ConcatenateStrings](@firststringvarchar(100),@secondstringvarchar(100), @concatenated varchar(200) out)ASBEGINset @concatenated= @firststring+&apos; &apos;+@secondstringENDCreate PROCEDURE [dbo].[concat](@firststringvarchar(100),@secondstringvarchar(100))ASBEGINselect @firststring+&apos; &apos;+@secondstring as fs;END
  2. create table testtbl (n int, name varchar(100))create function [dbo].[concat](@firststringvarchar(100),@secondstringvarchar(100))returns varchar(500)ASBEGINreturn @firststring+&apos;&apos;+@secondstringEND
  3. Create table Test_DBFit(name varchar(50), luckyNumberint)
  4. create TABLE [dbo].[Users]( [UserId] [int] IDENTITY(1,1) NOT NULL, [UserName] [varchar](50) NULL, [Name] [varchar](50) NULL, CONSTRAINT [PK_Users_UserId] PRIMARY KEY CLUSTERED ( [UserId] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]
  5. Create table Test_DBFit(name varchar(50), luckyNumberint)
  6. ALTER PROCEDURE [dbo].[ConcatenateStrings](@firststringvarchar(100),@secondstringvarchar(100), @concatenated varchar(200) out)ASBEGINset @concatenated= @firststring+&apos; &apos;+@secondstringENDcreate procedure Multiply (@factor int, @valint out)as beginset @val =@val*@factor;end