riserrad / RuntSQLtTests-AzDO

A pipeline task to run tSQLt tests and extract its results and Code Coverage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

##[warning]Invalid results file. Make sure the result format of the file 'TEST-Results.xml' matches 'JUnit' test results format.

Waylon58 opened this issue · comments

With lengthy XML, the results file contains carriage return characters every 2033 characters which in some cases causes the XML to be invalid. In my case, the carriage return occurs within an element name which causes the XML to be invalid. At this time I'm unable to provide a sample file, but the problem is discussed at https://stackoverflow.com/questions/42792915/sqlcmd-and-or-powershell-wrapping-xml-output

To verify that the problem only occurs with the generated file, I ran the same tSQLt tests from SQL Management Studio and saved the results to a file. Then I used that file as the source in DevOps. Everything worked in that case.

I am having this same issue.

To see the results XML file, I added a Command Line Task with the following YAML:

steps:
- script: 'more "$(System.DefaultWorkingDirectory)\tSQLt-out\TEST-Results.xml"'
  displayName: 'DEBUG - Output JUnit XML to log'

This resulted in the following log output (with ellipsis for cutting off the very long lines):

2019-05-17T23:45:14.2111140Z <testsuites><testsuite id="1" name="Test_4201_B_AddDefault"...
2019-05-17T23:45:14.2113787Z ="0" failures="0" timestamp="2019-05-17T23:44:09" time="4.8...
2019-05-17T23:45:14.2115284Z "test NULLs_in_HasXYError_column_should_be_counted" time="0...
2019-05-17T23:45:14.2116598Z assname="Test_44908_Error_Counts_TH_Helper" name="test NULL...
2019-05-17T23:45:14.2117443Z nts_MO_Helper" name="test E_FL_LoadTypeId_defaulting_to_1_s...
2019-05-17T23:45:14.2118097Z effectivedate_are_equal_then_more_recent_createddatetime_en...

When the Publish Test Results Task (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=yaml) runs on this file, I get the following warning:

2019-05-17T23:45:20.0408255Z ##[warning]Failed to read D:\a\r1\a\tSQLt-out\TEST-Results.xml. Error : 'assname' is an unexpected token. The expected token is '='. Line 4, position 1..

which you will notice is the start of the fourth line of the command line output.

Thanks @Waylon58 ! For the issue and for the contribution!

The code is now merged.