GoEddie / SQLCover

Apache License 2.0
63 stars 53 forks source link

How to exclude database objects from coverage reports? #72

Closed KrylixZA closed 10 months ago

KrylixZA commented 3 years ago

Hey @GoEddie :)

Thanks for this awesome library. I am running some tests against our DB in a Docker container in a CI pipeline and while there's nothing necessarily wrong, I am trying to figure out how to exclude objects from coverage. There appears to be little (to possibly no) documentation no how to do the exclusions correctly?

The SQLCover.CodeCoverage (PowerShell) has a couple of options, the one I am interested is: New-Object SQLCover.CodeCoverage($connectionString, $DbName, $ObjectFilters, $DebugLogging)

It seems to support the notion of filtering out objects but I actually don't know how to do this 😢

Any help would be nice.

In particular, I have two schemas on my DB:

I would like to exclude the Versioning schema from coverage.

priyasomangali commented 3 years ago

Hi @GoEddie ,

I am also looking to tackle similar issue reported above. My usecase is to exclude a list of stored procedures for which I Know I will not write unit tests. In that scenario, I would want to exclude those in the total coverage metrics as well. Could you help suggest if this is possible in the existing version ?

Thanks, Priya

priyasomangali commented 3 years ago

Hello @KrylixZA ,

Were you able to find any solution for the issue you have reported ? Please let me know if you have found something.

Thanks, Priya

priyasomangali commented 3 years ago

hi @KrylixZA ,

Found a working solution where sql objects can be excluded from coverage.

$excludeArray = “\[dbo\].\[sp_sysproc1\]","\[dbo\].\[sp_sysproc2\]” $coverage = new-object SQLCover.CodeCoverage($connectionString, $database, $excludeArray, $logging)

Referece : https://the.agilesql.club/2016/04/sqlcover-code-coverage-for-sql-server-t-sql/

Thanks

KrylixZA commented 10 months ago

hi @KrylixZA ,

Found a working solution where sql objects can be excluded from coverage.

$excludeArray = “\[dbo\].\[sp_sysproc1\]","\[dbo\].\[sp_sysproc2\]” $coverage = new-object SQLCover.CodeCoverage($connectionString, $database, $excludeArray, $logging)

Referece : https://the.agilesql.club/2016/04/sqlcover-code-coverage-for-sql-server-t-sql/

Thanks

Closing this issue with this comment. Thanks @priyasomangali 👍