GoEddie / GoEddie/SQLCover

Exception calling "Cover" with "1" argument(s) - also "2" arguments.

Open
#44 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
TSQL
Stars
69
Forks
55
PR merge metrics
No merged PRs in 30d

Description

**Do you want to request a *feature* or report a *bug*?**
*bug* or help

**What is the current behavior?**

I am getting the following when calling Get-CoverTSql. Where is the debug output?

```
Exception calling "Cover" with "1" argument(s): "Unable to start the trace - errors are recorded in the debug output"
At C:\Users\hoffman\Documents\Apps\SQLCOver.0.4.1\SQLCover.ps1:19 char:2
+ $coverage.Cover($query)
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : SqlCoverException
```
Also tried using Get-CoverExe and is got an error message from `OSQL.EXE` indicating that I didn't set up the arg list correctly. The relevant line is commented out below.
```
Error: No user selected. Try with -U or -E switches
You cannot call a method on a null-valued expression.
At C:\Users\hoffman\Documents\Apps\SQLCOver.0.4.1\SQLCover.ps1:89 char:5
+ $result.OpenCoverXml() | Out-File $xmlPath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvokeMethodOnNull
```
Server version:
Microsoft SQL Server 2017 (RTM-CU15) (KB4498951) - 14.0.3162.1 (X64) May 15 2019 19:14:30 Copyright (C) 2017 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2012 R2 Datacenter 6.3 (Build 9600: ) (Hypervisor)

**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via http://sqlfiddle.com/
```
# 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}" "${connectionString}" "${database}" "${osql}" "${osqlArgs}"
Export-OpenXml $result "testout.xml"
```
**What is the expected behavior?**
Not receiving an error message

**Which versions of SQL Server and which OS are affected by this issue? Did this work in previous versions of our procedures?**

Microsoft SQL Server 2017 (RTM-CU15) (KB4498951) - 14.0.3162.1 (X64) May 15 2019 19:14:30 Copyright (C) 2017 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2012 R2 Datacenter 6.3 (Build 9600: ) (Hypervisor)

Client desktop computer: Windows 10 Enterprise
Version 1806 (OS Build 17134.1006)

First time attempting to use SQLCover.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with SQLCover.ps1 at the reported calls on lines 19 and 89, and inspect the Get-CoverTSql and Get-CoverExe entry points. Reproduce the supplied test.ps1 scenario with SQL Server 2017, checking how trace errors and the OSQL argument list are surfaced. Done means both entry points report actionable errors instead of the Cover and null-expression failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.