Giter VIP home page Giter VIP logo

Comments (6)

ncbidoug avatar ncbidoug commented on August 30, 2024 1

I got the original error again with 0.4.1 and 0.5.0
Code:

# https://stackoverflow.com/questions/9948517/how-to-stop-a-powershell-script-on-the-first-error
$ErrorActionPreference = "Stop"  
cd c:\Users\hoffman\Documents\Apps\SQLcover
# https://the.agilesql.club/2016/04/sqlcover-code-coverage-for-sql-server-t-sql/
$coverPath='C:\Users\hoffman\Documents\Apps\SQLCOver-0.5.0'
$coverPS1="$coverPath\SQLCover.ps1"
$coverDLL="$coverPath\SQLCover.dll"
$server='GTR_DEV16'
$database='GTR'
$SQLuser='gtr_write'
$SQLpass='removed'
$query="EXEC tSQLt.Run 'zut_clinvar_sub_curation.Test_update_sub_date'"
$connectionString = "User ID=$SQLuser;Password=$SQLpass;database=$database;Server=$server;"
Unblock-File -Path $coverDll
Add-Type -Path $coverDll
. $coverPS1
$coverage = new-object SQLCover.CodeCoverage ($connectionString, $database, $null, $true)
$result = $coverage.Cover($query)
Export-OpenXml $result "testout.xml"

Output

.\short_test.ps1

Starting Code Coverage
Starting Code Coverage...Done
Executing Command: EXEC tSQLt.Run 'zut_clinvar_sub_curation.Test_update_sub_date'
Executing Command: EXEC tSQLt.Run 'zut_clinvar_sub_curation.Test_update_sub_date'...done
Stopping Code Coverage
Exception calling "Cover" with "1" argument(s): "Exception gathering the results"
At C:\Users\hoffman\Documents\Apps\SQLcover\short_test.ps1:19 char:1
+ $result = $coverage.Cover($query)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : SqlCoverException

Adding a second argument, 0, didn't help.

from sqlcover.

GoEddie avatar GoEddie commented on August 30, 2024

Hi,

For the debug output run this:

$coverage = new-object SQLCover.CodeCoverage ($connectionString, $databaseName, $null, $true)
$coverage.Cover($query)

so for your script run:

# file: test.ps1 
$ErrorActionPreference = "Stop"  

cd c:\Users\hoffman\Documents\Apps\SQLcover

# https://the.agilesql.club/2016/04/sqlcover-code-coverage-for-sql-server-t-sql/
$coverPath='C:\Users\hoffman\Documents\Apps\SQLCOver.0.4.1'
$coverDLL="$coverPath\SQLCover.dll"
$coverPS1="$coverPath\SQLCover.ps1"
# osql and osqlArgs used for Get-CoverExe
$osql='C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\OSQL.EXE'
$server='GTR_DEV16'
$database='GTR'
$SQLuser='gtr_write'
$SQLpass='removed'  # 
$query="EXEC tSQLt.Run 'zut_clinvar_sub_curation.Test_update_sub_date'"
$connectionString = "Persist Security Info=False;User ID=$SQLuser;Password=$SQLpass;Initial Catalog=$database;Server=$server"
$osqlArgs="-S $server -d $database -U $SQLuser -P $SQLpass -i test.sql"
. $coverPS1
#$result = Get-CoverTSql "${coverDLL}" "${connectionString}" "${database}" "${query}"
#$result = Get-CoverExe "${coverDLL}"
$coverage = new-object SQLCover.CodeCoverage ($connectionString, $database, $null, $true)
$result = $coverage.Cover($query)

Can you tell me the error?

ed

from sqlcover.

ncbidoug avatar ncbidoug commented on August 30, 2024

Thank you for your response. I had another error which I reported and have since deleted because it was an unrelated internal problem. Disregard whatever email was generated as a result. I apologize for the inconvenience.

from sqlcover.

GoEddie avatar GoEddie commented on August 30, 2024

Hi,

no problem - can you clarify what error you get now?

There is also a newer release 0.5.0 which has a number of big fixes, probably worth testing with:

https://github.com/GoEddie/SQLCover/releases/tag/0.5.0

from sqlcover.

ncbidoug avatar ncbidoug commented on August 30, 2024

I am having permission issues and working with our DBA. Thanks for letting me know about the new version.

from sqlcover.

lastlink avatar lastlink commented on August 30, 2024

@ncbidoug I would try the SQLCoverCore project using dotnet core 3.1. You can also use the debugger in visual studio code to track down your issue. I think correcting your powershell script would take more time than using the easier dll.

Example using dotnet core:

cd src/SQLCover/SqlCoverCore
mkdir -p TestCoverageOpenXml
dotnet run -- -c Get-CoverTSql -e Export-OpenXml -k "Server=localhost;Database=master;User ID=sa;Password=JdMsKZPBBA8kVFXVrj8d" -d DatabaseWithTests -q "tSQLt.runAll" -o TestCoverageOpenXml

you can also call the new dll directly, (not to be confused w/ the one targeting .net461

cd src/SQLCover/SqlCoverCore
dotnet build
.\bin\Debug\netcoreapp3.1\SQLCoverCore.exe -c Get-CoverTSql -e Export-OpenXml -k "Server=localhost;Database=master;User ID=sa;Password=JdMsKZPBBA8kVFXVrj8d" -d DatabaseWithTests -q "tSQLt.runAll" -o TestCoverageOpenXml
# or 
dotnet run .\bin\Debug\netcoreapp3.1\SQLCoverCore.dll -- -c Get-CoverTSql -e Export-OpenXml -k "Server=localhost;Database=master;User ID=sa;Password=JdMsKZPBBA8kVFXVrj8d" -d DatabaseWithTests -q "tSQLt.runAll" -o TestCoverageOpenXml

from sqlcover.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.