You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test Attachments are not added to trx file after test run is done on linux environment.
Repro steps
Create Nunit tests project with the only test, which adds some existing file to attachments.
Build project and start test execution with command: dotnet vstest "/path/to/project.dll" /logger:"trx" /ResultsDirectory:./test-results /Diag:./diag/diag.main.log
Wait until test execution is finished. Take a look at terminal messages, it says that 1 of 1 tests passed.
Check created trx file
Expected result : the trx file contains section with a test attachment with correct file path; Actual result : the trx file contains stderr section for the executed test:
<StdErr>Failed to attach files from: Attachments
Error Details: System.InvalidOperationException:System.InvalidOperationException: This operation is not supported for a relative URI.
at System.Uri.get_LocalPath()
at Microsoft.TestPlatform.Extensions.TrxLogger.Utility.Converter.ToResultFiles(AttachmentSet attachmentSet, Guid testResultExecutionId, TestRun testRun, String trxFileDirectory)
at Microsoft.TestPlatform.Extensions.TrxLogger.Utility.Converter.UpdateTestResultAttachments(TestResult rockSteadyTestResult, TestResult testResult, TestRun testRun, String trxFileDirectory, Boolean addAttachments)</StdErr>
Analysis
I digged into adapter code, checked mstest logic and test execution logs(./diag/diag.main.log).
The reason of the problem is that adapter sends straigh file path to mstest's executor, without file:// URI schema.
So, for example, path /absolute/path/to/attachment.txt is a correct absolute path on linux environment, but mstest consider it as a relative path when it deserializes the data which was recieved from adapter. The path is deserialized without errors, but calling property .LocalPath(line 510) on relative uri causes exception from the repro steps.
I modified adapter code locally and added "file://" in the beginning of the file path right before attachment item creation. After that I built adapter dll and made my test project use that modified dll. Attachments were added to trx file without any error.
Other details
NUnit Version
3.10.1
NUnit3TestAdapter
3.10.0
dotnet sdk
2.1.301
vstest.console.exe
15.7.0
OS
Ubuntu 18.04 LTS
Last Updated : 2018/07/04
The text was updated successfully, but these errors were encountered:
I updated the description as I looked into the problem a bit dipper than before.
I got the reason of the problem (more-less), but I'm not sure where it should be fixed.
My opinion is to add file:// schema right before attachment DTO for vstest.console.
I didn't check mstest code carefully and don't know how exactly mstest converts execution message from json to object.
Summary
Test Attachments are not added to trx file after test run is done on linux environment.
Repro steps
dotnet vstest "/path/to/project.dll" /logger:"trx" /ResultsDirectory:./test-results /Diag:./diag/diag.main.log
Expected result : the trx file contains section with a test attachment with correct file path;
Actual result : the trx file contains stderr section for the executed test:
Analysis
I digged into adapter code, checked mstest logic and test execution logs(./diag/diag.main.log).
The reason of the problem is that adapter sends straigh file path to mstest's executor, without file:// URI schema.
So, for example, path
/absolute/path/to/attachment.txt
is a correct absolute path on linux environment, but mstest consider it as a relative path when it deserializes the data which was recieved from adapter. The path is deserialized without errors, but calling property .LocalPath(line 510) on relative uri causes exception from the repro steps.I modified adapter code locally and added "file://" in the beginning of the file path right before attachment item creation. After that I built adapter dll and made my test project use that modified dll. Attachments were added to trx file without any error.
Other details
Last Updated : 2018/07/04
The text was updated successfully, but these errors were encountered: