{"id":70236,"date":"2017-03-08T18:00:05","date_gmt":"2017-03-08T18:00:05","guid":{"rendered":"https:\/\/www.simple-talk.com\/?p=70236"},"modified":"2021-06-03T16:48:24","modified_gmt":"2021-06-03T16:48:24","slug":"using-dbfit-framework-data-warehouse-regression-testing","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/using-dbfit-framework-data-warehouse-regression-testing\/","title":{"rendered":"Using the DbFit Framework for Data Warehouse Regression Testing"},"content":{"rendered":"<p>How do you, or should you, automate database testing? If you have a technique for doing so, how can you extend this for testing a data warehouse? How easy is it to use? There are some established tools that are designed for testing databases, and the <a href=\"https:\/\/en.wikipedia.org\/wiki\/FitNesse\">FitNesse framework<\/a> is one of the best for user-acceptance tests. In this article I aim to demonstrate enough to get you started with using DbFit for regression-testing a SQL Server Data Warehouse.<\/p>\n<h2>DbFit for the Job?<\/h2>\n<p>DbFit is a member from FitNesse framework. FitNesse is an implementation of the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Framework_for_integrated_test\">Framework for Integrated Test (FIT)<\/a> testing framework. DbFit is specially designed and developed for database testing.<\/p>\n<p>In DbFit, the test cases are written in a simple text format. The DbFit test cases are designed to work with simple SQL queries and stored procedures.<\/p>\n<p>There were six major reasons why we implemented DbFit within our DevOps environment. It was easy to use with our existing CI tools, the test cases were easy to write, we could extend it for our specialized requirements, DbFit worked smoothly with Excel, It was easy for the database developers to understand, and there was a good web-based GUI that everyone can use.<\/p>\n<ol>\n<li style=\"list-style-type: none\">\n<ol>\n<li>\n<p><strong>Support for XCopy Deployment<\/strong> <br \/>\nDbFit test-cases can be executed from a web interface or from a command line. Because of the command line support, it is very easy to integrate with the continuous integration tools for XCopy deployment.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none\">\n<ol>\n<li>\n<p><strong>Wiki Test cases<\/strong> <br \/>\nAll the test cases are written in simple wiki format. It is easy to understand and aid for better communication between technical and non-technical stakeholders.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none\">\n<ol>\n<li>\n<p><strong>Highly extensible framework<\/strong> <br \/>\nThe DbFit framework can be extended using java or .Net languages.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none\">\n<ol>\n<li>\n<p><strong>Export and Import test cases using Excel <\/strong> <br \/>\nThe DbFit has good interoperability with Excel. The test cases can be written in Excel and imported into DbFit. Also DbFit does support to export the test cases as Excel sheets.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none\">\n<ol>\n<li>\n<p><strong>Developer\u2019s friend<\/strong> <br \/>\nIt enable the database developers to access the database objects in tabular format. This helps the database developers to adopt the framework easily.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li>\n<p><strong>Web interface to manage test cases <\/strong> <br \/>\nDbFit has a fantastic GUI (frontend) to manage the test cases. Test cases can be created and edited in the front end. The test cases can be executed as a single test case or a suite (collection of test cases).This GUI helps a tester or anyone to create test cases without the knowledge of scripting.<\/p>\n<\/li>\n<\/ol>\n<h2>DbFit for regression test:<\/h2>\n<p>The DbFit can be used to regression-test both the database metadata and the data itself. Testing the metadata will disclose the unexpected changes in database objects such as tables, views or stored procedures, whereas testing the data will disclose the unexpected changes to the data coming from the ETL packages.<\/p>\n<p>In this article we will concentrate about testing the data in the Data warehouse, and cover these areas in detail.<\/p>\n<h2><img loading=\"lazy\" decoding=\"async\" width=\"1109\" height=\"292\" class=\"wp-image-70237\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/word-image-10.png\" \/><\/h2>\n<h2>Installation &amp; Configuration:<\/h2>\n<p>In this section I will explain how to install DbFit, and set up the necessary configuration on your local machine.<\/p>\n<h3>Pre-requisite:<\/h3>\n<p>We need Java Runtime Environment (JRE) 7 or higher to set-up DbFit. The JRE can be downloaded from Oracle website <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/jre8-downloads-2133155.html\">here<\/a>.<\/p>\n<h3>Installation:<\/h3>\n<p>You can download DbFit from the web site <a href=\"http:\/\/dbfit.github.io\/dbfit\/\">here<\/a>. Once the zip file has been downloaded then you can unzip the contents to a folder.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"581\" height=\"174\" class=\"wp-image-70238\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/word-image-11.png\" \/><\/p>\n<p>Contents of the zip file can be seen as per the image below<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"581\" height=\"356\" class=\"wp-image-70239\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/word-image-12.png\" \/><\/p>\n<h3>Starting DbFit Service:<\/h3>\n<p>The DbFit framework can be started by running the \u201cstartFitnesse.bat\u201d file. It may take few minutes to start for the first time.<\/p>\n<p>If, as a result, you can see this, it confirms that the DbFit service has been started successfully.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"653\" height=\"282\" class=\"wp-image-70240\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-d.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\DbFit_Startup.png\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"653\" height=\"282\" class=\"wp-image-70241\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-d-1.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\DbFit_Startup.png\" \/><\/p>\n<p>Once the DbFit package is up and running, the service can be accessed using the URL <code>http:\/\/localhost:8085\/<\/code> in a browser as shown below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"818\" height=\"534\" class=\"wp-image-70242\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-d-2.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\DbFit_Homepage.png\" \/><\/p>\n<h3>Stopping the service:<\/h3>\n<p>The DbFit service can be stopped by pressing Ctrl+C on the MSDOS command prompt. The prompt \u2018Terminate Batch Job (Y\/N)\u2019, shown below, means that the service is about to be stopped.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"657\" height=\"302\" class=\"wp-image-70243\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-s.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\Stopping.png\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"657\" height=\"302\" class=\"wp-image-70244\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-s-1.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\Stopping.png\" \/><\/p>\n<h3>Connecting to SQL Server:<\/h3>\n<p>Because of licensing restrictions, the database drivers are not available with DbFit by default. Instead, we need to download them manually and then copy the files across to the DbFit folder.<\/p>\n<p>Unfortunately, DbFit does not connect to SQL Server by default. We need to install the JDBC driver and configure it to use in the DbFit framework. These steps will help you to install the driver and connect to SQL server.<\/p>\n<h3>Installing JDBC driver:<\/h3>\n<p>The JDBC driver for SQL Server can be downloaded from Microsoft website <a href=\"https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=11774\">here<\/a>.<\/p>\n<p>It is best to download the zip file \u201csqljdbc_6.0.8112.100_enu.tar.gz\u201d. Once downloaded, unzip the contents to a folder.<\/p>\n<p>You will be able to locate the JDBC driver file \u201csqljdbc42.jar\u201d in the folder:<\/p>\n<p>\u201c..\\sqljdbc_6.0.8112.100_enu.tar\\sqljdbc_6.0.8112.100_enu\\sqljdbc_6.0\\enu\\jre8\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"588\" height=\"370\" class=\"wp-image-70245\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-j.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\JDBC_Driver.png\" \/><\/p>\n<p>Now copy the JDBC driver file into the DbFit lib folder (..\\DbFit-complete-3.2.0\\lib), as shown in the image below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"581\" height=\"400\" class=\"wp-image-70246\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-j-1.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\JDBC_Driver_Deployment.png\" \/><\/p>\n<p>This has enabled us to connect the SQL server from DbFit, but if you would prefer to connect using the more secure Windows authentication, then you will need to follow one more additional configuration step, which I\u2019ll now explain.<\/p>\n<h3>Setting up Windows authentication:<\/h3>\n<p>The assembly (sqljdbc_auth.dll) can be found on the folder \u201c..\\sqljdbc_6.0.8112.100_enu.tar\\sqljdbc_6.0.8112.100_enu\\sqljdbc_6.0\\enu\\auth\\x64\u201d.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"582\" height=\"367\" class=\"wp-image-70247\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-s-2.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\SQLAuth.png\" \/><\/p>\n<p>\u2026so copy this file to the JRE folder C:\\Program Files (x86)\\Java\\jre1.8.0_121\\bin as shown in the next screenshot.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"585\" height=\"408\" class=\"wp-image-70248\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-s-3.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\SQlAuth_Deployment.png\" \/><\/p>\n<h2>Setting up a sample test case:<\/h2>\n<p>Now that the DbFit package has been set up successfully, we will now create a sample test case.<\/p>\n<p>Open <code>http:\/\/localhost:8085\/SampleSQLTest<\/code> in your browser. You should see an editor where you can create and run your test case (page).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"713\" height=\"469\" class=\"wp-image-70249\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-s-4.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\SampletestCase.png\" \/><\/p>\n<p>This will create a blank test case as shown in the image below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"812\" height=\"326\" class=\"wp-image-70250\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-s-5.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\SampletestCaseEdit.png\" \/><\/p>\n<p>Test cases are created in a wiki markup which is a simple text format. The representation is very similar to the relational model. Hence you can create DbFit test cases without the help of programming language.<\/p>\n<p>Test cases can be grouped logically in a test suite. DbFit expect you to follow Camel Casing when you give the name to a test case or a suit.<\/p>\n<p>In addition, the test cases can be created in Excel and imported from Excel to DbFit interface using the button \u201cSpreadsheet to FitNesse\u201d.<\/p>\n<p>Test cases are actually stored on the file system in a simple text format. You can create and edit them using a text editor such as Notepad or Notepad++.<\/p>\n<p>The additional drivers for DbFit need to be loaded into FitNesse to support the execution of tests. This can be achieved by loading the relevant libraries in the test case using this command<\/p>\n<pre>!path lib\/*.jar<\/pre>\n<p>The line below indicates that DbFit will try to connect to MSSQL Server database. This helps DbFit to use the correct driver to execute the test case.<\/p>\n<pre>!|DbFit.SqlServerTest|<\/pre>\n<p>More information can be found <a href=\"http:\/\/dbfit.github.io\/dbfit\/docs\/getting-started.html\">here<\/a> for other RDBMS.<\/p>\n<p>This line indicates the connection settings for the SQLServer<\/p>\n<pre>!|Connect|localhost|DbFit_user|password|DbFit|<\/pre>\n<p>In DbFit, a SQL query can be executed using the Query command. The SQL query has to be defined after the command <strong>\u201c!|Query\u201d<\/strong> . We need to define the expected result set structure in the next line. Here, the result set will have only one column \u201cX\u201d. This is represented below.<\/p>\n<pre>|x|<\/pre>\n<p>The subsequent rows define the expected results. It is enough to specify just the columns that you\u2019re interested within the result set. In this example, we are expecting only one value (\u201ctest\u201d) that is shown below.<\/p>\n<p>\u201c|test|\u201d<\/p>\n<p>Now all we now need to do is to copy the complete test case shown below, and paste it in the text box to create a test case. I will be using the JDBC driver to connect to SQL server and use Windows authentication to connect.<\/p>\n<pre>!path lib\/*.jar\r\n  !|DbFit.SqlServerTest|\r\n  !|Connect|jdbc:sqlserver:\/\/localhost\\sql2012;integratedSecurity=true|\r\n  !|Query| select 'test' as X|\r\n  |x|\r\n  |test|<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"774\" height=\"391\" class=\"wp-image-70251\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-s-6.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\Sampletestcasewithcode.png\" \/><\/p>\n<p>Once done, click the \u2018<em>save<\/em>\u2019 button to create a test case. Now the test page will look like this.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"607\" height=\"390\" class=\"wp-image-70252\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-t.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\TestCaseAfterCompletion.png\" \/><\/p>\n<p>Now the test case can be executed by clicking the \u2018<em>Test<\/em>\u2019 button the header. The test case will, hopefully, be successful as shown in the image below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"820\" height=\"505\" class=\"wp-image-70253\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-t-1.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\TestResultExecution1.png\" \/><\/p>\n<h3>Failure Case:<\/h3>\n<p>Now let\u2019s update the test case with an invalid SQL expression (\u201c<strong>SELECT GetDate1()\u201d)<\/strong> So that the test case will fail. Here we can see a failure case.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"818\" height=\"337\" class=\"wp-image-70254\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-i.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\InvalidTestcase.png\" \/><\/p>\n<p>This represents the completion of the test case, and the test has failed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"884\" height=\"480\" class=\"wp-image-70255\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-t-2.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\TestResultCaseFailure.png\" \/><\/p>\n<h3>Command line execution:<\/h3>\n<p>The DbFit test cases can be run from the command line. This is great for any DevOps environment because this will help us to integrate the DbFit with the Continuous Integration (CI) tools.<\/p>\n<p>This command line will help you to run the test page \u201cSampleSQLTest\u201d in DbFit<\/p>\n<pre>Java -jar \".\\lib\\fitnesse-20150424-standalone.jar\" -c \"SampleSQLTest?test&amp;format=text\"<\/pre>\n<p>Here we can see the successful execution of the test case from the Command line.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"659\" height=\"326\" class=\"wp-image-70256\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-c.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\CommandLineExecution.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>Naming Convention for Test Case:<\/h3>\n<p>There are two simple rules to follow while creating a test page name in DbFit<\/p>\n<ul>\n<li>The test page name has to start with an uppercase letter and should have one more uppercase letter in the name<\/li>\n<li>All the uppercase letters have to be separated by at least one lowercase letter.<\/li>\n<\/ul>\n<h2>Sample Test case Hierarchy<\/h2>\n<p>The DbFit package supports the hierarchical classification of the test cases. This can be achieved by creating a test-suite page. A suite is a collection of related test cases (pages) in DbFit. A test suite will run all the test pages defined in the hierarchy and we can see the results of all test cases in a single page.<\/p>\n<p>This will help us to access the overall test results of a specific system.<\/p>\n<h3>Creating a Suite:<\/h3>\n<p>A suite can be created by typing the name with the suffix \u201csuite\u201d in the browser as follows.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"626\" height=\"206\" class=\"wp-image-70257\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-c-1.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\CreatingSuit.png\" \/><\/p>\n<p>Now we can see a suite \u201cAdventureWorks\u201d page has been created. Under this suite base-page, we can create the hierarchy of all the test cases.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"304\" class=\"wp-image-70258\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-c-2.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\CreatingSuit1.png\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"629\" height=\"275\" class=\"wp-image-70259\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-c-3.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\CreatingSuit2.png\" \/><\/p>\n<p>As I would like to set-up a hierarchy of the test cases, I am planning to create further child suites for Staging, Dimension and Fact. These suites will hold the relevant test cases. A child suite page can be created by clicking on the <strong>Add-&gt; Suite<\/strong> page link.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"597\" height=\"276\" class=\"wp-image-70260\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-c-4.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\ChildSuitePage.png\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"676\" height=\"386\" class=\"wp-image-70261\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-c-5.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\CreatingDimensionTestSuite.png\" \/><\/p>\n<p>Now, the dimension test suite has been created successfully. In addition, I have added few suites to create a hierarchy within the <strong>AdventureWorks<\/strong> suite as shown below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"528\" height=\"319\" class=\"wp-image-70262\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-m.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\MultipleChildSuites.png\" \/><\/p>\n<h3>Setting up connection details in a file:<\/h3>\n<p>In the previous test case, we have mentioned the name of the server and the database in the test page itself. However the connection details will change over time and will vary from server to server. So it is a much better idea to maintain the connection details in a separate configuration file.<\/p>\n<p>Now I have added the connection configuration file in the root folder.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"506\" height=\"262\" class=\"wp-image-70263\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-c-6.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\ConfigFileLocation.png\" \/><\/p>\n<p>The contents of this connection configuration file is this.<\/p>\n<pre>#DbFit connection properties<\/pre>\n<p>Connection-string=jdbc:sqlserver:\/\/localhost\\sql2012;integratedSecurity=true;<\/p>\n<p>You can now use these stored connection configurations within a test script by using the Connect using file command with the URL of the configuration file, in this case \u2026<\/p>\n<pre>!|Connect using file|.\\FitNesseRoot\\AdventureWorksSuite\\ConnectionConfig.txt|<\/pre>\n<p>I show how to reference this within a test case in the next section.<\/p>\n<p>So far we have learned about setting up a test hierarchy in DbFit. Now we can apply this methodology to build a regression test for a Data Warehouse.<\/p>\n<h3>Regression Test for Data Warehouse:<\/h3>\n<p>Let\u2019s assume we have developed a SSIS package to load the data from staging to the Data warehouse table \u201cDimCurrency\u201d. To enable us to regression test the data load to this table, we need to have another test table with the expected data. Let us assume that we have prepared the data in the test table \u201c<strong>DimCurrency_Test<\/strong>\u201d. Now we need to compare both the \u201c<strong>DimCurrency<\/strong>\u201d and the \u201c<strong>DimCurrency<\/strong>_<strong>Test<\/strong>\u201d table for each test iteration.<\/p>\n<p>Test table with expected data : dbo.DimCurreny_Test<\/p>\n<p>Target table (for SSIS load) : dbo.DimCurreny<\/p>\n<p>After the successful completion of Data warehouse load, you would expect that the number of records between the <strong>DimCurrency<\/strong> and the <strong>DimCurrency_Test<\/strong> tables are the same.<\/p>\n<p>The table structure and the data of the <strong>DimCurrency<\/strong> table can be seen below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"267\" class=\"wp-image-70264\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-d-3.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\DimCurrency.png\" \/><\/p>\n<p>The table structure and the data of the <strong>DimCurrency<\/strong>_<strong>Test<\/strong> table can be seen below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"671\" height=\"261\" class=\"wp-image-70265\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-d-4.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\DimCurrencyTestTable.png\" \/><\/p>\n<p>Now we\u2019ll create the \u201c<strong>DimCurrencyTest<\/strong>\u201d test case under the \u201c<strong>Dimension<\/strong>\u201d suite to compare the data between the target and the test table.<\/p>\n<p>Test Case content:<\/p>\n<pre>!path lib\/*.jar\r\n  !|DbFit.SqlServerTest|\r\n  !|Connect using file|.\\FitNesseRoot\\AdventureWorksSuite\\ConnectionConfig.txt|\r\n  !|Store Query|Select [CurrencyKey],[CurrencyAlternateKey],[CurrencyName] from [AdventureWorksDW2008R2].[dbo].[DimCurrency]|query1|\r\n  !|Store Query|Select [CurrencyKey],[CurrencyAlternateKey],[CurrencyName] from [AdventureWorksDW2008R2].[dbo].[DimCurrency_Test]|query2|\r\n  !|Compare Stored Queries Hide Matching Rows|query1|query2|\r\n  |CurrencyAlternateKey|CurrencyName?|<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"871\" height=\"304\" class=\"wp-image-70266\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-v.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\ValidateDimCurrencyTestCase.png\" \/><\/p>\n<p>Now we can see how DbFit can validate for different test cases.<\/p>\n<h3>Test Case 1: Both the target table and test table has got same data (and same number of records)<\/h3>\n<p>The screenshot below shows how DbFit confirms that we are able to successfully regression-test the <strong>DimCurrency<\/strong> table because we are able to successfully compare the data against <strong>DimCurrency<\/strong>_<strong>Test<\/strong> table.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"878\" height=\"598\" class=\"wp-image-70267\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-v-1.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\ValidateDimCurrencyTestCaseSuccessful.png\" \/><\/p>\n<h3>Test Case 2: Missing record in <strong>DimCurrency<\/strong><\/h3>\n<p>Now let\u2019s assume that the SSIS package has a defect and has missed a record to load in the <strong>DimCurreny<\/strong> table. To replicate this test case in the <strong>DimCurrency<\/strong> table, I will be deleting a record for the currency \u201cCZK\u201d.<\/p>\n<p>I have deleted the currency using the SQL below.<\/p>\n<pre>Delete from [AdventureWorksDW2008R2].[dbo].[DimCurrency]\r\nwhere CurrencyAlternateKey='CZK'\r\n<\/pre>\n<p>Now let\u2019s re run the test case to validate the results. The test case has correctly identified the missing record.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"906\" height=\"625\" class=\"wp-image-70268\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-m-1.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\MissingRecordsInDimCurrency.png\" \/><\/p>\n<h3>Test Case 3: Record with an incorrect column value<\/h3>\n<p>Now I have inserted a record to add the Czech currency. However I have deliberately mistyped the currency name as \u201cCzech Dollar\u201d instead of \u201cCzech Koruna\u201d using this SQL.<\/p>\n<pre>Insert into [dbo].[DimCurrency] (CurrencyAlternateKey,CurrencyName)\r\nValues ('CZK','Czech Dollar')\r\n<\/pre>\n<p>Now I would like the DbFit framework to compare the values and notify me the difference between the expected and actual columns values. Let\u2019s run the test case to access the results.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"721\" height=\"608\" class=\"wp-image-70269\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-i-1.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\IncorrectColumnValue.png\" \/><\/p>\n<p>The DbFit framework has correctly identified the incorrect column value and highlighted the expected and actual column values for comparison.<\/p>\n<p>So far, we have created a test case for a dimension table. Now we\u2019ll create a test case for the staging table and concentrate on creating a test hierarchy.<\/p>\n<h3>Testing the suite hierarchy:<\/h3>\n<p>Now I have created a \u201c<em>Staging<\/em>\u201d suite under the AdventureWorks suite to group all staging-related test cases.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"554\" height=\"356\" class=\"wp-image-70270\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-s-7.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\SuiteHierarchy.png\" \/><\/p>\n<p>I have added two test cases to validate records in the <strong>Sales<\/strong>.<strong>Currency<\/strong> and <strong>Production<\/strong>.<strong>UnitMeasure<\/strong> staging tables. Now these test cases can be tested alone or these can be executed from the suite.<\/p>\n<p>I can see what test cases are available under the \u201c<em>Staging<\/em>\u201d suite.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"639\" height=\"377\" class=\"wp-image-70271\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-s-8.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\StagingSuiteHierarchy.png\" \/><\/p>\n<p>Now I can execute the staging suite to validate the results of all these test cases, by clicking on the \u201c<em>Suite<\/em>\u201d link.<\/p>\n<p>The result of executing all of the tests in the staging suite with all the test cases will be shown as in this screenshot.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"564\" class=\"wp-image-70272\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-s-9.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\StagingSuiteHierarchyExecution.png\" \/><\/p>\n<p>In addition we have defined a parent test suite \u201cAdventureWorksSuite\u201d in the root.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"456\" height=\"290\" class=\"wp-image-70273\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-a.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\AdventureWorksSuiteHierarchy.png\" \/><\/p>\n<p>If we then execute the suite, we will see the following test summaries.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"566\" class=\"wp-image-70274\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-a-1.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\AdventureWorksSuiteHierarchyExecution.png\" \/><\/p>\n<p>Executing a Suite from command line:<\/p>\n<p>This command line will help you to run the suite \u201cAdventureWorksSuite\u201d in DbFit<\/p>\n<pre>Java -jar \".\\lib\\fitnesse-20150424-standalone.jar\" -c \"AdventureWorksSuite?suite&amp;format=text\"<\/pre>\n<p>Here we can see the successful execution of the suite from the Command line.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1130\" height=\"258\" class=\"wp-image-70275\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/c-workarea-nat-sql-blog-simpletalk-dbfit-images-t-3.png\" alt=\"C:\\WorkArea\\Nat\\SQL\\Blog\\SimpleTalk\\DbFit\\Images\\TestingSuite.png\" \/><\/p>\n<h2>DbFit limitations<\/h2>\n<p>There are few noticeable limitations of DbFit . It is designed to test the accuracy of a system, but it is not suitable for performance or load testing because it is unable to compare more than 10000 rows: Also, user-defined database types are not supported.<\/p>\n<h2>Conclusion<\/h2>\n<p>One of the key aspect of building a regression test framework is to prepare good test data, and the experts in judging what the data should be are in the business rather than IT. It is impractical to have to use systems for tests that have to be devised by IT people if it is for the purposes of verifying a business process. This means providing a verification system that can be created and used directly by anyone without IT training, beyond using Excel and a Wiki. Preparing business-oriented test data is a challenging task, because the business requirements are highly volatile and change substantially over time. Once you have a reasonable supply of test data that is provided directly by the business, audit and accountancy experts, you can use DbFit to improve the quality, design and maintainability of your Data Warehousing application.<\/p>\n<h2>Reference links:<\/h2>\n<ul>\n<li><a href=\"http:\/\/dbfit.github.io\/dbfit\/docs\/\">DbFit documentation<\/a><\/li>\n<li><a href=\"https:\/\/www.simple-talk.com\/dotnet\/.net-tools\/acceptance-testing-with-fitnesse,-the-overview\/\">FitNesse Introduction\u00a0 and Walkthrough<\/a><\/li>\n<li><a href=\"https:\/\/www.simple-talk.com\/dotnet\/.net-tools\/acceptance-testing-with-fitnesse-documentation-and-infrastructure\/\">Fitnesse Documentation and Infrastructure<\/a><\/li>\n<li><a href=\"https:\/\/www.simple-talk.com\/dotnet\/.net-tools\/acceptance-testing-with-fitnesse--naming-and-layout\/\">Fitnesse Naming and Layout<\/a><\/li>\n<li><a href=\"https:\/\/www.simple-talk.com\/dotnet\/net-tools\/acceptance-testing-with-fitnesse-debugging-control-flow-and-tracing\/\">Fitnesse Debugging, Control Flow, and Tracing<\/a><\/li>\n<li><a href=\"https:\/\/www.simple-talk.com\/dotnet\/.net-tools\/acceptance-testing-with-fitnesse-symbols,-variables-and-code-behind-styles\/\">Fitnesse Symbols, Variables, and Code-Behind Style<\/a><\/li>\n<li><a href=\"https:\/\/www.simple-talk.com\/dotnet\/.net-tools\/acceptance-testing-with-fitnesse-multiplicities-and-comparisons\/\">Fitnesse Multiplicities and Comparisons<\/a><\/li>\n<li><a href=\"https:\/\/www.simple-talk.com\/dotnet\/.net-tools\/acceptance-testing-with-fitnesse-database-fixtures,-project-overview\/\">Fitnesse Database Fixtures, Project Overview<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>It is ironic that the users of database application need to rely on the very technologists that created the system to then devise and run their acceptance tests. Surely someone has devised a test system for databases that is simple enough for ordinary tech-savvy people to use and for them to create the tests?  Yes they have. Fitnesse DbFit is a mature product that can, and does, test SQL Server databases, and Nat Sundar explains how to set it up and do it.&hellip;<\/p>\n","protected":false},"author":189139,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143531],"tags":[],"coauthors":[39133],"class_list":["post-70236","post","type-post","status-publish","format-standard","hentry","category-t-sql-programming-sql-server"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/70236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/189139"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=70236"}],"version-history":[{"count":4,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/70236\/revisions"}],"predecessor-version":[{"id":72818,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/70236\/revisions\/72818"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=70236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=70236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=70236"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=70236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}