GoEddie / SQLCover

Apache License 2.0
63 stars 52 forks source link

Generating partial test coverage report for the Azure DB. #66

Open Riddhish84 opened 3 years ago

Riddhish84 commented 3 years ago

Describe the bug I have run the Power shell for SQL coverage report for Azure DB, it shows me partial sqlunit test coverage as well and some time it is covering more or less test cases. I wrote SQL Unit Tests with SQL Server Data Tools.

To Reproduce

I have made script to run all azure test cases and to get sql cover report.


$coverDllPath =  "C:\Downloads\SQLCover-0.5.0\SQLCover-0.5.0\src\SQLCover\releases\template\SQLCover.dll"

$connectionString = "Server=server_name;Database=db_name;Persist Security Info=False;User ID=master;Password=pa$$word;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
$databaseName = "db_name"

$outputPath ="C:\Downloads\SQLCover-0.5.0\SQLCover-0.5.0\src\SQLCover\releases\template\result"

if(!(Test-Path $coverDllPath)){
Write-Error "SQLCover.dll path was not found ($coverDllPath)"
return
}

Unblock-File -Path $coverDllPath

Add-Type -Path $coverDllPath

$coverage = new-object SQLCover.CodeCoverage ($connectionString, $databaseName)

$coverage.Start()

# Run all test cases .
mstest.exe /testcontainer:C:\Project\test_project\bin\Debug\RamSoft.AzureSQL.Test.dll

$result = $coverage.Stop() 

$xmlPath = Join-Path -Path $outputPath -ChildPath "Coverage.html"
    $result.Html() | Out-File $xmlPath
    $result.SaveSourceFiles($outputPath) 

Snapshot image image

As you can see only I have test cases which executes more than 1000 statements but it covers partially.

Expected behavior Should cover all the statements of the test cases

Additional context

I am using latest version of SQLCover i.e. 0.5.0. I unlocked the SQLcover.dll as well. It run all the test cases means it is trigger the statements. But not covered all of them while generating cover report. I have also tried with CoverExe function but it gave same result for me. I have also tried to increase timeout, but it had same results

Please @GoEddie help me to solve this issue.

lowlydba commented 3 years ago

Looks like a dup of https://github.com/GoEddie/SQLCover/issues/51

Riddhish84 commented 3 years ago

I think in #51, 0 line covered for azure sql but in this scenario we have partial coverage report.

lowlydba commented 3 years ago

It varies if you do enough testing, most likely the same problem.

umeshsolanki19 commented 1 year ago

Hi @GoEddie, I am also facing same issue(coverage report is showing 0 line coverage and sometime showing partial coverage) with Azure SQL database and I think it's an existing issue with SQLCover for Azure Sql database. Could you please share some workaround for this issue? Thanks!