Feature request: dynamic location for TestResult.xml

Bug #697069 reported by Patrick Simon
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
NUnit Framework
Fix Released
Medium
Charlie Poole
NUnit V2
Fix Released
Low
Charlie Poole

Bug Description

Feature Request: provide an option to include the run date and time somewhere in the full path for the NUnit result file, TestResult.xml. Ideally, that path would either originate in a test fixture, or else originate in the NUnit framework, and be made available to the tests in a test fixture, so they could send output to the same directory.

To illustrate the request with a specific example: suppose all tests in a test fixture output diagnostic information to a directory named "test run <run-date-time>", where "<run-date-time>" is the date and time of the construction of the test fixture at run time. The purpose of this request is to provide some way to output the NUnit result file TestResult.xml to the same directory.

Possible mechanisms to provide this feature, or something equivalent:

1. Allow a TestFixture (or other class or method) to specify the output path for TestResult.xml.

2. Provide for a macro in NUnit's configurable output path for TestResult.xml, such that the date and time are included in the path, and make that path available to test fixtures and tests.

3. Provide a post-processing step after TestResult.xml has been written, where a named batch file could be run. Code in a test or test fixture could dynamically generate the contents of that file, ex. copy TestResult.xml "test run 2011-01-03-2300".

Tags: feature

Related branches

tags: added: feature
Revision history for this message
Charlie Poole (charlie.poole) wrote :

Comments on the proposed mechanisms...

1. This associates a global option with a particular fixture, which doesn't seem right. It also opens the possibility that more than one TestFixture might specify the location, requiring code in NUnit to either resolve which to use (or randomly pick one) or issue an error message at test load time.

2. This could easily be done in the command-line processing for nunit-console but would make sense in normal gui use, since
the location of saving the file as well as it's name can be specified interactively.

3. I'm not clear on this one. If NUnit is run from a batch file, it's of course possible to run any desired commands after the test run based on the return code. It doesn't seem that reversing the sequence by having NUnit invoke the batch file provides any more flexibility than what's already available.

If we do this, I think #2 is most likely approach. The priority seems low, since it can be done now through a script. On the other hand, it's fairly easy to do.

Changed in nunitv2:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Patrick Simon (psimon111) wrote :

Right, this feature is not really needed when running NUnit tests from a batch script, because a script can specify a path and copy files around as needed. It would potentially be useful when running NUnit tests through the GUI or when running tests in a debugger.

Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 697069] Re: Feature request: dynamic location for TestResult.xml

It wouldn't apply to the Gui, since the Gui doesn't have a command-line option
to redirect the XML output. In the Gui, you simply use a menu item to save
the result wherever you like.

On Tue, Jan 4, 2011 at 8:18 PM, Patrick Simon <email address hidden> wrote:
> Right, this feature is not really needed when running NUnit tests from a
> batch script, because a script can specify a path and copy files around
> as needed.  It would potentially be useful when running NUnit tests
> through the GUI or when running tests in a debugger.
>
> --
> You received this bug notification because you are a member of NUnit
> Developers, which is subscribed to NUnit V2.
> https://bugs.launchpad.net/bugs/697069
>
> Title:
>  Feature request: dynamic location for TestResult.xml
>

Changed in nunitv2:
milestone: none → 2.6.0
Revision history for this message
xconspirisist (xconspirisist) wrote :

> It wouldn't apply to the Gui, since the Gui doesn't have a command-line option
> to redirect the XML output. In the Gui, you simply use a menu item to save
> the result wherever you like.

The GUI creates a TestResult.xml in the current working directory which is awkward. The issue would be resolved for me if the path to TestResult.xml is configurable in the .nunit configuration file.

Revision history for this message
Charlie Poole (charlie.poole) wrote :

The configuration file (nunit.exe.config) is being de-emphasized and
current settings
are in the process of being migrated to the NUnit settings file
(NUnitSettings.xml).

However, this is for settings that apply to all executions of NUnit.
For settings that
pertain to a single project, the nunit project file seems like the
most likely place.
For settings that pertain to a single run, the command line is used.

Charlie

On Mon, Mar 28, 2011 at 12:28 PM, xconspirisist <email address hidden> wrote:
>> It wouldn't apply to the Gui, since the Gui doesn't have a command-line option
>> to redirect the XML output. In the Gui, you simply use a menu item to save
>> the result wherever you like.
>
> The GUI creates a TestResult.xml in the current working directory which
> is awkward. The issue would be resolved for me if the path to
> TestResult.xml is configurable in the .nunit configuration file.
>
> --
> You received this bug notification because you are a member of NUnit
> Developers, which is subscribed to NUnit V2.
> https://bugs.launchpad.net/bugs/697069
>
> Title:
>  Feature request: dynamic location for TestResult.xml
>

Revision history for this message
Patrick Simon (psimon111) wrote :

The feature requested in this issue is already implementable in NUnit 2.5.10, by implementing an NUnit EventListeners extension. It was relatively straightforward to add code to the RunFinished event listener to create a second copy of TestResult.xml in a target working directory for a test run.

Changed in nunitv2:
assignee: nobody → Charlie Poole (charlie.poole)
status: Triaged → In Progress
Revision history for this message
Charlie Poole (charlie.poole) wrote :

The solution implemented uses the already-existing (in 2.6) /work option, which allows the user to specify the directory to be used for all output files, including TestResult.xml. Users may set this option using a script so that it includes the date and time in any desired format. If the option is not used, the current directory is the work directory.

Access to this path from tests is now provided using TestContext.WorkDirectory.

Changed in nunitv2:
status: In Progress → Fix Committed
Changed in nunit-3.0:
milestone: none → 2.9.6
Changed in nunit-3.0:
status: New → Triaged
importance: Undecided → Medium
Changed in nunitv2:
status: Fix Committed → Fix Released
Changed in nunit-3.0:
status: Triaged → Fix Committed
assignee: nobody → Charlie Poole (charlie.poole)
Changed in nunit-3.0:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.