File - testRUN New Zealand

Report
DbFit 3.0.1 for FitNesse
with Data Warehouse worked examples
Presented by Chris SAUNDERS - September 2014
@chrisrsaunders
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
99% Presentation
Presenter’s Background [2%]
Audience Survey [4%]
DbFit Intro [5%]
Data Warehouse Intro [8%]
Worked Examples [75%]
Discussion [5%]
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Presenter’s Background
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Chris SAUNDERS
a little more background…
Test & Agile Practitioner
One who practices testing & agile software development,
as a professional occupation.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Chris SAUNDERS
Originally a Systems Engineer. Spent a decade on my OE in the United Kingdom.
Returned to Christchurch as a Test Manager; contracted for 5 years & now permanent.
Local Government
Healthcare
Christchurch
Utilities
Education
Auckland
New Zealand
Payroll
Tauranga
Palmerston North
Aviation
Healthcare
Wellington
2008
Christchurch
School &
Polytechnic
Education
Degree Education
Bachelor of Technology
(Honours), Information
Engineering
Graduated 1997
United
Kingdom
Financial Services
Stirling
Power Generation
Massey University
Edinburgh
Harrogate
Stockport
Fashion IT
1999
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Audience Survey
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Audience Survey
Who…
has used FitNesse?
has used DbFit?
has worked with Data Warehouses?
has an understanding SQL?
(Structured Query Language)
SELECT DISTINCT Drink
FROM the.Fridge
WHERE Temperature = 'Cold'
AND Drink IN (
'Coke'
,'Ginger Beer'
)
AND (
Quality > 0
OR Quality IS NOT NULL
)
What is the result of the following SQL?
(Bottom table is the Fridge table)
dbo is the "default" schema for SQL Server;
(database owner)
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
DbFit Intro
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
What is DbFit?
DbFit is a set of fixtures which enables FIT/FitNesse tests to
execute directly against a database.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
What is DbFit?
DbFit is a set of fixtures which enables FIT/FitNesse tests to
execute directly against a database.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
What is DbFit?
DbFit is a set of fixtures which enables FIT/FitNesse tests to
execute directly against a database.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Data Warehouse Intro
Environment
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Data Warehouse Environment
ETL
[AdventureWorks2014]
Extract
Source Data
(multiple sources)
[AdventureWorksDW2014]
Transform
Load
Load
Stage
Data Warehouse
Person
Person
WorkingPerson
DimPerson
BusinessEntityID
BusinessEntityID
EmployeeKey
EmployeeKey
FirstName
FirstName
BusinessEntityID
FirstName
LastName
LastName
FirstName
LastName
MiddleName
MiddleName
LastName
MiddleName
PersonType
PersonType
MiddleName
SalesPersonFlag
…
…
SalesPersonFlag
…
…
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
What Point to Test
[AdventureWorks2014]
[AdventureWorksDW2014]
Extract
Source Data
(multiple sources)
Transform
Load
Load
Stage
Source
Source
Data Warehouse
Data Warehouse
Load
Data Warehouse
Load
DbFit 3.0.1 for FitNesse
Stage
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
What Point to Test
Considered each possible test points on the threads.
Load
Test Points
To test the whole system, one needs each thread.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Data Warehouse Intro
Facts & Dims
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Facts & Dimensions
Dimension Table
Fact Table
[AdventureWorksDW2014].[dbo]. [FactResellerSales]
•
•
Consists of the measurements, metrics
or facts of a business process
Calculations can be done on the measures
(e.g. sum, count, min, max)
DbFit 3.0.1 for FitNesse
[AdventureWorksDW2014].[dbo].[DimEmployee]
•
Provides filtering, grouping and labelling
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Worked Examples
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Connection to the Database
Connect command
Specifying the full connection string using the full ADO.NET or JDBC connection string.
or
Specifying server, username, password, and database name.
Connect Using File command
A file contains the connection information, therefore can be environment related.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Count Data Warehouse Records
table DimCustomer
[AdventureWorks2014]
[AdventureWorksDW2014].[dbo].[DimCustomer]
ETL
Known
Source Data
Data Warehouse
Data Warehouse
COUNT
18444
Check Data Warehouse table DimCustomer count record against a fixed value in
FitNesse wiki page.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Count Data Warehouse Records
Query command with fixed result
Brittle test due to the fact this test requires updating every time test data changes as
the DimCustomer table record will change.
Which SQL for COUNT and why?
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Count Data Warehouse Records
table FactInternetSales
[AdventureWorksDW2014].[dbo].[FactInternetSales]
[AdventureWorks2014]
ETL
Known
Source Data
COUNT
Source
Data Warehouse
Data Warehouse
COUNT
Check Data Warehouse table FactInternetSales count records against a Source data.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Count Data Warehouse Records
Store Query command
Compare stored queries command
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Visualise SQL with
Design Query in Editor
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Sum Data Warehouse fields
UnitPrice, table FactInternetSales
[AdventureWorksDW2014].[dbo].[FactInternetSales]
[AdventureWorks2014]
ETL
Known
Source Data
SUM
Source
Data Warehouse
Data Warehouse
SUM
Check Data Warehouse field’s UnitPrice total sum in table FactInternetSales, against a
Source data.
Measures can be summed up, for all records or for a sub-set of records.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Sum Data Warehouse fields
Store Query command
Compare stored queries command
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Check each Data Warehouse field,
ListPrice in table DimProduct
[AdventureWorks2014]
[AdventureWorksDW2014].[dbo].[DimProduct]
ETL
Known
Source Data
Source
Data Warehouse
Data Warehouse
EXCEPT (both ways)
Check each Data Warehouse ListPrice field, in table DimProduct, against Source data.
SQL’s EXCEPT function, returns any distinct values from the left query that are not also
found on the right query.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Check each Data Warehouse field
Limit number of errors in FitNesse.
TOP 3
Return results in the same order.
ORDER BY 1, 2
(or else missing records will be displayed)
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Lets Change Focus
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Test Database
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Test Database
[AdventureWorksDW2014]
[DbFitNesseTest]
data
Test Database
Data Warehouse
Data Warehouse
Test Database is used for:
• Store Test data (either as a source or created from other sources)
• Store procedures (to be executed from FitNesse)
• Storing results (to compare in the future)
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Test Database
Report User Story Example
European Internal Sales Report
As an European Sales Manager,
I want a Report on total “Europe Internal Sales" for each year,
So that future business decisions can be made.
Acceptance Criteria : 1. To include all available years
2. Only 3 countries; France, UK & Germany
3. …
Year France
Germany
UnitedKingdom
2014
$0.00
$0.00
$0.00
2013 $1,578,511.80 $1,761,876.36 $2,124,007.29
2012 $648,065.54 $608,657.98
$712,700.96
2011 $410,845.33 $520,500.16
$550,591.22
2010
$3,399.99
$0.00
$699.10
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Test Database
[AdventureWorksDW2014]
[DbFitNesseTest]
data
Test Database
Data Warehouse
Data Warehouse
Create a table with expected results.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Create Expected Results Table
Execute command
Commit command
Create a table and commit to database.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Truncate Expected Results Table
Inspect Table command
Truncate table and commit to database.
Inspect Table to confirm it’s truncated (does not Pass or Fail).
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Insert into Expected Results Table
Insert command
Insert data into table and
commit to database.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Count Data Warehouse Records
Store Query command
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Count Data Warehouse Records
Compare Stored Queries command
Data
0.00
Rounding
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Count Data Warehouse Records
Compare Stored Queries command
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Drop Expected Results Table
Drop table and commit to database.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Other Commands
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Other Commands
Update command
Execute Procedure command
Update command similar to insert command.
Execute Procedure will executes a stored procedure or function for each row of data
table and will bind input/output parameters to columns of the data table.
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Thank you
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours
Adventure Works 2014 Sample Databases
http://msftdbprodsamples.codeplex.com/releases/view/125550
Microsoft SQL Server 2014 Express
http://msdn.microsoft.com/en-us/evalcenter/dn434042.aspx
Poor Man's T-SQL Formatter
http://www.architectshack.com/PoorMansTSqlFormatter.ashx
DbFit examples
http://www.testrun.co.nz/presentations.html (place under FitNesseRoot\DbFit\AcceptanceTests\DotNetTests)
DbFit 3.0.1 for FitNesse
with Data Warehouse worked examples
Presented by Chris SAUNDERS - September 2014
@chrisrsaunders
DbFit 3.0.1 for FitNesse
Chris SAUNDERS B.Tech (Info. Eng.) with Honours

similar documents