1

I use Fluent Assertions in Visual Studio when I write automated tests in C#/Selenium. I HAVE PLACED AN INTENTIONAL FAILED ASSERTION IN MY CODE to demonstrate the problem. The output looks fine on Failed soft assertions in my runs on Dev Studio. In ADO, the log in the pipeline run when I use VSTest@2 also looks fine (see Pic). But, when I go to Test Runs and log at the failed assertion there, the Published results show "&#39" for single quotes (see pic). These are not my own single quotes, soft assertion puts them in there. Again, they look fine in one place (ADO pipeline log) and do NOT look fine in ADO test run results.

In the pics, the Azure DevOps Pipeline run correctly shows single quotes that Fluent Assertion puts in. In Dev Studio it is also shown correctly, but in Azure DevOps when you go to Test Plans->Runs you can see the (Intentionally) failed test shows "&#39" for the single quotes instead (which is how Ascii represents a single quote). Fluent Assertions NUGET package is very popular and works well as show in the 2nd pic. VSTest@2 in pipeline generates the test run results that show the rogue char representation.

Any advice? Thanks

I expect the ADO VSTest@2 test run results to NOT have "&#39" in them for single quotes (just as the ADO Pipeline output)

Ascii value of single quote shown in assertion on ADO test run (but not in ADO Pipeline test log)

I found my answer but I am not being allowed to answer. I had an Override for ToString that came from FluentAssertions. You can see in the code here the single quotes are NOT escaped. I can either remove them, or escape them. I chose to remove them, but I verified it with them escaped as well. Fixed. Thanks.

ANSWER

  • Seems ``'`` is not the problem, you excpect ``$36.8`` but got ``$36.80`` – sa-es-ir Apr 20 '23 at 13:33
  • 1
    Thanks but no that was an intentional fail to show the problem – Chris LaVenture Apr 20 '23 at 13:33
  • Yes I have an assertion failure. I did that intentionally to show the problem. In the pics, the Azure DevOps Pipeline run correctly shows single quotes that Fluent Assertion puts in. In Dev Studio it is also shown correctly, but in Azure DevOps when you go to Test Plans->Runs you can see the (Intentionally) failed test shows "'" for the single quotes instead (which is how Ascii represents a single quote). Fluent Assertions NUGET package is very popular and works well as show in the first pic. VSTest@2 in pipeline generates the test run results that show the rogue char representation. – Chris LaVenture Apr 20 '23 at 13:40
  • I found the problem. I had an Override for ToString that came from FluentAssertions. You can see in the code here the single quotes are NOT escaped. I can either remove them, or escape them (like this: \'). I chose to remove them, but I verified it with them escaped as well. Fixed. Thanks. public override string ToString() { return $"{_message}*Assertion was expected to be " + $"'{_expected}' but was '{_actual}'"; } – Chris LaVenture Apr 20 '23 at 15:35
  • 2
    Won't let me post the answer. Here is a pic of my answer. Thanks. Have a nice day. – Chris LaVenture Apr 20 '23 at 15:42

0 Answers0