* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download File
Microsoft SQL Server wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Relational model wikipedia , lookup
Functional Database Model wikipedia , lookup
@testrunnz testrun.co.nz ETL [AdventureWorks2014] Extract Source Data (multiple sources) [AdventureWorksDW2014] Transform Load Load Stage Data Warehouse DbFit 3.0.1 for FitNesse with Data Warehouse worked examples Chris SAUNDERS - September 2014 @testrunnz testrun.co.nz Audience Survey @testrunnz testrun.co.nz Audience Survey Who… has used FitNesse? has used DbFit? has worked with Data Warehouses? has an understanding SQL? (Structured Query Language) What is the result of the following SQL? (Bottom table is the Fridge table) dbo is the "default" schema for SQL Server; (database owner) SELECT DISTINCT Drink FROM the.Fridge WHERE Temperature = 'Cold' AND Drink IN ( 'Coke' ,'Ginger Beer' ) AND ( Quality > 0 OR Quality IS NOT NULL ) @testrunnz testrun.co.nz DbFit Intro @testrunnz testrun.co.nz What is DbFit? DbFit is a set of fixtures which enables FIT/FitNesse tests to execute directly against a database. @testrunnz testrun.co.nz What is DbFit? DbFit is a set of fixtures which enables FIT/FitNesse tests to execute directly against a database. @testrunnz testrun.co.nz What is DbFit? DbFit is a set of fixtures which enables FIT/FitNesse tests to execute directly against a database. @testrunnz testrun.co.nz Data Warehouse Intro Environment @testrunnz testrun.co.nz Data Warehouse Environment ETL [AdventureWorks2014] Extract [AdventureWorksDW2014] Transform Load Source Data (multiple sources) Load Stage 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 … … Data Warehouse @testrunnz testrun.co.nz 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 Stage @testrunnz testrun.co.nz What Point to Test Considered each possible test points on the threads. Load Test Points To test the whole system, one needs each thread. @testrunnz testrun.co.nz Data Warehouse Intro Facts & Dims @testrunnz testrun.co.nz 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) [AdventureWorksDW2014].[dbo].[DimEmployee] • Provides filtering, grouping and labelling @testrunnz testrun.co.nz Worked Examples @testrunnz testrun.co.nz 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. @testrunnz testrun.co.nz 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. @testrunnz testrun.co.nz 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? @testrunnz testrun.co.nz 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. @testrunnz Count Data Warehouse Records Store Query command Compare stored queries command testrun.co.nz @testrunnz Visualise SQL with Design Query in Editor testrun.co.nz @testrunnz testrun.co.nz 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. @testrunnz Sum Data Warehouse fields Store Query command Compare stored queries command testrun.co.nz @testrunnz testrun.co.nz 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. @testrunnz testrun.co.nz 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) @testrunnz testrun.co.nz Lets Change Focus @testrunnz testrun.co.nz Test Database @testrunnz testrun.co.nz 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) @testrunnz testrun.co.nz 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 @testrunnz testrun.co.nz Test Database [AdventureWorksDW2014] [DbFitNesseTest] data Test Database Data Warehouse Data Warehouse Create a table with expected results. @testrunnz Create Expected Results Table Execute command Commit command Create a table and commit to database. testrun.co.nz @testrunnz 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). testrun.co.nz @testrunnz testrun.co.nz Insert into Expected Results Table Insert command Insert data into table and commit to database. @testrunnz Count Data Warehouse Records Store Query command testrun.co.nz @testrunnz testrun.co.nz Count Data Warehouse Records Compare Stored Queries command Data 0.00 Rounding @testrunnz Count Data Warehouse Records Compare Stored Queries command testrun.co.nz @testrunnz Drop Expected Results Table Drop table and commit to database. testrun.co.nz @testrunnz testrun.co.nz Other Commands @testrunnz testrun.co.nz 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. @testrunnz testrun.co.nz Thank you @testrunnz testrun.co.nz 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