tSQLt-org / tSQLt

The official tSQLt repository. (Download at: http://tSQLt.org/downloads )
http://tSQLt.org
411 stars 102 forks source link

XmlResultFormatter does not work with sqlcmd on Linux #54

Open nsturmwind opened 4 years ago

nsturmwind commented 4 years ago

In order to use the sqlcmd utility to export test results in xml format it is necessary to both use the:XML ON directive and pass the -y0 flag to sqlcmd in order to get the full output. However, the :XML ON directive is not supported in the Linux version of sqlcmd.

As an alternative, casting to nvarchar(max) and using the -y0 flag works, including on Linux. However, tSQLt.XmlResultFormatter does not allow any way to do this cast. It is not possible via INSERT .. EXEC .., since FOR XML cannot be used within INSERT .. EXEC ...

TheConstructor commented 3 years ago

Just out of curiosity: have you tried mssql-cli? I did not yet have the chance to try it.

mbt1 commented 2 years ago

This could be implemented as an tSQLt.JUnitResultFormatter, as to not change existing behavior.

peterhirn commented 1 year ago

Workaround for go-sqlcmd

Windows

$env:SQLCMDMAXVARTYPEWIDTH=0
sqlcmd -d test -h-1 -Q "set nocount on; exec tSQLt.XmlResultFormatter" -o results.xml

Linux

SQLCMDMAXVARTYPEWIDTH=0 sqlcmd -d test -h-1 -Q "set nocount on; exec tSQLt.XmlResultFormatter" -o results.xml