{"id":19811147,"url":"https://github.com/accenture/dbtestcomparegenerator","last_synced_at":"2025-09-18T05:32:11.945Z","repository":{"id":76965080,"uuid":"344065263","full_name":"Accenture/DBTestCompareGenerator","owner":"Accenture","description":"Tool for generating database tests","archived":false,"fork":false,"pushed_at":"2024-12-03T09:09:24.000Z","size":252,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-12-03T10:23:36.234Z","etag":null,"topics":["compare-data","database","database-migrations","sqlserver","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Accenture.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-03T09:07:48.000Z","updated_at":"2024-12-03T09:09:28.000Z","dependencies_parsed_at":"2024-02-26T09:46:55.650Z","dependency_job_id":"39ba9966-8422-4654-9ccf-8cc793fde879","html_url":"https://github.com/Accenture/DBTestCompareGenerator","commit_stats":null,"previous_names":["accenture/dbtestcomparegenerator"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Accenture%2FDBTestCompareGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Accenture%2FDBTestCompareGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Accenture%2FDBTestCompareGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Accenture%2FDBTestCompareGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Accenture","download_url":"https://codeload.github.com/Accenture/DBTestCompareGenerator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233451303,"owners_count":18678211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compare-data","database","database-migrations","sqlserver","testing-tools"],"created_at":"2024-11-12T09:24:59.189Z","updated_at":"2025-09-18T05:32:11.937Z","avatar_url":"https://github.com/Accenture.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"DBTestCompareGenerator/images/DBTestCompareGenerator_logo.png\" alt=\"DBTestCompareGenerator_logo\" width=\"200\"\u003e\n\n# DBTestCompareGenerator\n\n## Tool for generating database tests that can be run with **[DBTestCompare](https://github.com/Accenture/DBTestCompare)**\n### And extracting and unpacking DACPAC **Microsoft SQL Server DAC Package File** using [DacFx package](https://github.com/microsoft/DacFx).\n\n![DBTestCompare Build](https://github.com/Accenture/DBTestCompareGenerator/actions/workflows/github-actions.yml/badge.svg)\n\nSupported databases: **SQL Server**\n\nAI generated documentation [DeepWiki](https://deepwiki.com/Accenture/DBTestCompareGenerator)\n\nIt reads the definition of tables to be tested from system tables of your database and generates tests which can be executed by [DBTestCompare](https://github.com/Accenture/DBTestCompare/wiki/Getting-started) application. \n\n```sql\nSELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME,COLUMN_NAME, IS_NULLABLE, DATA_TYPE \nFROM INFORMATION_SCHEMA.COLUMNS  \norder by 1,2,3;\n```\n![table-definition](https://github.com/Accenture/DBTestCompareGenerator/blob/master/DBTestCompareGenerator/images/table-definition.png)\n\n### 1. To start using **DBTestCompareGenerator** download the latest [release](https://github.com/Accenture/DBTestCompareGenerator/releases) and set connection string to your database in *appsettings.json* file.\n\n```json\n{\n  \"appSettings\": {\n    \"ReadExcelFile\": \"false\",\n    \"GenerateCountSmokeTests\": \"true\",\n    \"GenerateCompareFetchTests\": \"true\",\n    \"GenerateCompareMinusTests\": \"true\",\n    \"ColumnTypesToGroupBy\": \"nvarchar,nchar,datetime,date,bit\",\n    \"DBNameLiveMinusTests\": \"AdventureWorks2008R2\",\n    \"DBNameBranchMinusTests\": \"AdventureWorks2008R2Branch\",\n    \"ConnectionStrings\": {\n      \"DB\": \"User ID=SA;Password=yourStrong22Password;Initial Catalog=AdventureWorks2008R2;Data Source=localhost;\"\n    }\n  }\n}\n```\nand just run *DBTestCompareGenerator.exe* application on Windows or *DBTestCompareGenerator* on Linux.\n\nTests should be created in folder *\".\\test-definitions\\\"*\n\n### 2. To generate tests for **all tables** in database set *ReadExcelFile* to *false* in *appsettings.json*.\n\nDBTestCompareGenerator by default is creating three types of test:\n-\tSmoke tests – counting the number of rows in each of the tables. The number of rows is obtaining from the database system tables. \nQuery:\n```sql\nSELECT \n sum(cast(SysP.row_count as bigint)) \n FROM sys.dm_db_partition_stats as SysP \n inner join sys.indexes as SysI \n on SysP.object_id = SysI.object_id \n and SysP.index_id = SysI.index_id \n inner join sys.tables as SysT \n on SysP.object_id = SysT.object_id \n inner join sys.schemas as SysS \n on SysT.schema_id = SysS.schema_id \n WHERE \n SysI.[type] in (0, 1)  and SysS.name = 'Person' and SysT.name = 'Address'; \n ```\n Test Definition:\n ```xml\n \u003ccmpSqlResultsTest\u003e\n    \u003ccompare mode=\"FETCH\" fetchSize=\"100000\" chunk=\"10\" diffTableSize=\"5\" fileOutputOn=\"false\" delta=\"0.00001\"\u003e\n        \u003csql datasourceName=\"SQL_SERVER_Live\" filename=\"ExpectedTable.sql\" /\u003e\n        \u003csql datasourceName=\"SQL_SERVER_Branch\" filename=\"ActualTable.sql\" /\u003e\n    \u003c/compare\u003e\n\u003c/cmpSqlResultsTest\u003e\n ``` \n-\t[Fetch](https://github.com/Accenture/DBTestCompare/wiki/Fetch) tests – comparing two queries in DBTestCompare tool memory (between any two databases)\n```sql\nSELECT \n\"BusinessEntityID\", \n\"rowguid\", \n\"ModifiedDate\" \nFROM \n Person.BusinessEntity \norder by BusinessEntityID; \n ```\n Test Definition:\n ```xml\n \u003ccmpSqlResultsTest\u003e\n    \u003ccompare mode=\"FETCH\" fetchSize=\"100000\" chunk=\"10\" diffTableSize=\"5\" fileOutputOn=\"false\" delta=\"0.00001\"\u003e\n        \u003csql datasourceName=\"SQL_SERVER_Live\" filename=\"ExpectedTable.sql\" /\u003e\n        \u003csql datasourceName=\"SQL_SERVER_Branch\" filename=\"ActualTable.sql\" /\u003e\n    \u003c/compare\u003e\n\u003c/cmpSqlResultsTest\u003e\n ``` \n-\t[Minus](https://github.com/Accenture/DBTestCompare/wiki/Minus) test - compare two queries by db engine (on one server) using MINUS/EXCEPT Sql operator\n```sql\nSELECT \n\"AddressTypeID\" , \n\"Name\" , \n\"rowguid\" , \n\"ModifiedDate\" \nFROM \n AdventureWorks2008R2.Person.AddressType \n ```\n ```sql\nSELECT \n\"AddressTypeID\" , \n\"Name\" , \n\"rowguid\" , \n\"ModifiedDate\" \nFROM \n AdventureWorks2008R2Branch.Person.AddressType \n ```\n Test Definition:\n ```xml\n\u003ccmpSqlResultsTest\u003e\n    \u003ccompare mode=\"MINUS\" defaultDatasourceName=\"SQL_SERVER_Live\" diffTableSize=\"50\" fileOutputOn=\"false\" minusQueryIndicatorOn=\"true\"\u003e\n        \u003csql minusQueryIndicatorOccurence=\"1\" minusQueryIndicatorText=\"Expected\" filename=\"ExpectedTable.sql\" /\u003e\n        \u003csql minusQueryIndicatorOccurence=\"1\" minusQueryIndicatorText=\"Actual\" filename=\"ActualTable.sql\" /\u003e\n    \u003c/compare\u003e\n\u003c/cmpSqlResultsTest\u003e\n ``` \n \nYou should choose which tests you want to execute Minus or Fetch and disable one type in *appsettings.json*  as both are testing the same but in different way.\n \n### 3. If you want to choose for which tables generate tests, set *ReadExcelFile* to *true* in *appsettings.json* and fill in a list of tables in file */Templates/Table_Config.xlsx*.\n\n![Excel file](https://github.com/Accenture/DBTestCompareGenerator/blob/master/DBTestCompareGenerator/images/Excel.png)\n\nIn the excel file for e.g huge tables which comparing can be time-consuming, you can choose in AggregateByClause column of Excel file columns to be aggregated as SUM (for columns in the table contains numeric values). \n\n```sql\nSELECT \n sum(cast(ProductID as bigint)), sum(cast(SafetyStockLevel as bigint)), sum(cast(ReorderPoint as bigint)), sum(cast(StandardCost as money)), sum(cast(ListPrice as money)), sum(cast(Weight as decimal)), sum(cast(DaysToManufacture as bigint)), sum(cast(ProductSubcategoryID as bigint)), sum(cast(ProductModelID as bigint))\nFROM \n Production.Product\n```\nRest of the column types listed in *appsettings.json* \n```json\n\"ColumnTypesToGroupBy\": \"nvarchar,nchar,datetime,date,bit\"\n```\nwill be grouped and counted.\n```sql\nSELECT \n Color, count_big(*) AS CountNo \nFROM  Production.Product\ngroup by Color\norder by Color;\n```\n\n### 4. If you want to change any setting in *appsettings.json* in your CI tool you can use script [set-appsettings.ps1](https://github.com/Accenture/DBTestCompareGenerator/blob/master/DBTestCompareGenerator/set-appsettings.ps1).\n\n ```powershell\n .\\set-appsettings.ps1 \".\\\" \"appsettings.json\" \"appSettings\" \"ReadExcelFile\" \"true\" $true\n ```\n\n### 5. Before execution of your generated tests, you have to replace tokens in the connection definition file [cmpSqlResults-config.xml](https://github.com/Accenture/DBTestCompareGenerator/blob/master/DBTestCompareGenerator/Templates/cmpSqlResults-config.xml)\n\nYou can use for that attached PowerShell script [set-tokens-for-tests.ps1](https://github.com/Accenture/DBTestCompareGenerator/blob/master/DBTestCompareGenerator/set-tokens-for-tests.ps1)\n\n ```powershell\n.\\set-tokens-for-tests.ps1 -OutDir \".\\test-definitions\\\" -FileType \"cmpSqlResults-config.xml\" -token \"\\$\\{SQL_SERVER\\}|\\$\\{SQL_SERVERDBNAME\\}|\\$\\{SQL_SERVER_USERNAME\\}|\\$\\{SQL_SERVER_PASSWORD\\}\" -Value \"localhost|AdventureWorks2008R2|SA|yourStrong22Password\"\n ```\n \n### 6.To execute tests download the latest version of [DBTestCompare](https://github.com/Accenture/DBTestCompare) from [here](https://github.com/Accenture/DBTestCompare/releases) and [SQL Server JDBC Drivers](https://github.com/Accenture/DBTestCompare/wiki/Deploying-licensed-jdbc-drivers-(not-open-source)) \n\n### And run program (Java 8 must be installed first (JDK or JRE)):\nIf you set JAVA_HOME variable:\n```\njava -jar DBTestCompare-1.0-SNAPSHOT-jar-with-dependencies.jar\n```\nMore details can be found [here](https://github.com/Accenture/DBTestCompare/wiki/Getting-started)\n\n### 7. To extract and unpack DACPAC **Microsoft SQL Server DAC Package File** change following settings in *appsettings.json* \n\n```json\n    \"ExtractAllTableData\": \"false\",\n    \"ExtractApplicationScopedObjectsOnly\": \"false\",\n    \"VerifyExtraction\": \"false\",\n    \"IgnoreExtendedProperties\": \"false\",\n    \"IgnorePermissions\": \"false\",\n    \"SaveAsBaseline\": \"false\",\n    \"UnpackDacpac\": \"true\",\n    \"DacpacFolder\": \"c:\\\\ProjectPath\\\\Dacpac\",\n    \"Folder\": \"c:\\\\ProjectPath\\\\Definitions\",\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faccenture%2Fdbtestcomparegenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faccenture%2Fdbtestcomparegenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faccenture%2Fdbtestcomparegenerator/lists"}