Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRX report file folder inconsistent with XML report folder using .runsettings file #997

Closed
varnk opened this issue Jul 15, 2022 · 2 comments

Comments

@varnk
Copy link

varnk commented Jul 15, 2022

  • NUnit 3.13.3
  • NUnit3TestAdapter 4.2.1
  • Visual Studio 2017 Pro 15.9.49
  • .NET Framework 4.6.1

When using a .runsettings file and enabling TRX logging, the TRX logs are written relative to the solution dir of the VS project. However, the NUnit XML output is written relative to the NUnit WorkingDir folder. There seems to be no way to have the test result output files go to the same folder with the way the .runsettings file is interpreted by the plug-in.

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
    <RunConfiguration>
        <ResultsDirectory>.\TestResults</ResultsDirectory>   <!-- This path is relative to Solution Dir -->
    </RunConfiguration>

   <LoggerRunSettings>
       <Loggers>
         <Logger friendlyName="trx" enabled="True">
           <Configuration>
             <LogFileName>TestResults.trx</LogFileName>
           </Configuration>
         </Logger>
       </Loggers>
     </LoggerRunSettings>

    <NUnit>
        <TestOutputXml>.\TestResults</TestOutputXml>            <!-- This path is relative to WorkingDir -->
    </NUnit>
</RunSettings>

@OsirisTerje
Copy link
Member

OsirisTerje commented Jul 15, 2022

@varnk Correct!
The TRX logging is handled by the testhost, which know where the solution directory is, and can point to it using a relative path.
The test adapter only knows about the working directory, and have no information about where the solution directory is, so the output folder is relative to that working directory.

The adapter doesn't read the runsettings itself either - otherwise it could have used that file's location as a clue - instead the runsettings is passed down to the adapter from the testhost.

We have asked for such metadata to be present somewhere, e.g. runsettings structure, but there are none now. The adapter depends on the information it gets from the testhost.

That said, if you in your solutions establish a fixed convention for where you have placed your test projects, then you can use that information to point upwards to the solution directory and thus the TestResults folder.

@OsirisTerje
Copy link
Member

OsirisTerje commented Jul 16, 2022

I had to have another peak inside what we get from the testhost, and now I do see we actually get the solution directory and the test result directory in the runcontext (See TestRunDirectory). I am pretty sure that it was not present last time I checked, but I can ofc be wrong about that too.
I also see that the runsettings setting for the result directory is expanded out to an absolute path.

image

So, this issue is actually fixable.

In order to not break those who rely on the current folder, it will probably need a feature flag to switch behavior.

Thanks @varnk for making us aware of this!

OsirisTerje added a commit that referenced this issue Jul 27, 2022
OsirisTerje added a commit that referenced this issue Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants