Author Topic: Can I change the trace_out.txt file location?  (Read 2108 times)

0 Members and 1 Guest are viewing this topic.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Can I change the trace_out.txt file location?
« on: July 14, 2016, 05:06:04 AM »
Visual Studio 2012-2013 (at this case I don't use IDE 2015 version because it can't find my tests).

When I run my NUnit (v4.0.30319) tests in IDE without admin rights I get the error for each my test:

Quote
Result Message: OneTimeSetUp: System.UnauthorizedAccessException : It is denied access to the path "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\trace_out.txt".

But if I do the same with admin rights then all work fine. In the "Options" dialog I didn't find the property for pointing the custom location of this file. Is it possible? I don't want to work with admin rights...
« Last Edit: July 14, 2016, 05:09:18 AM by Andrey Bushman »

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Can I change the trace_out.txt file location?
« Reply #1 on: July 14, 2016, 05:42:56 AM »
Oh no... It is my mistake, instead of IDE.  :oops: I wrote my tests many time ago and now thought that this file was created and used by IDE.  :oops: But I found in my code that it is my file and my mistake:

Code - C#: [Select]
  1. [OneTimeSetUp]
  2. public void RunBeforeAnyTests() {
  3.     Stream traceFile = File.Create("trace_out.txt");
  4.     listener = new TextWriterTraceListener(traceFile);
  5.     Trace.Listeners.Add(listener);
  6. }
Earlier I launched the tests through the NUnit console application (instead of IDE) therefore problems weren't (the working directory was another). Now I changed settings of the project to launch tests in IDE and this error was appeared.

So I am to point the full path for the trace log file:
Code - C#: [Select]
  1. [OneTimeSetUp]
  2. public void RunBeforeAnyTests() {
  3.  
  4.     string dir = Path.GetDirectoryName(Assembly
  5.         .GetExecutingAssembly().Location);
  6.  
  7.     string trace_file_name = Path.Combine(dir,
  8.         "trace_out.txt");
  9.  
  10.     Stream traceFile = File.Create(trace_file_name);
  11.     listener = new TextWriterTraceListener(traceFile);
  12.     Trace.Listeners.Add(listener);
  13. }


I apologize for this stupid topic. Remove it, please.  :oops:

« Last Edit: July 14, 2016, 05:52:48 AM by Andrey Bushman »

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2139
  • class keyThumper<T>:ILazy<T>
Re: Can I change the trace_out.txt file location?
« Reply #2 on: July 14, 2016, 06:22:03 AM »

I'll leave it for education purposes Andrey, if you don't mind.

Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Atook

  • Swamp Rat
  • Posts: 1029
  • AKA Tim
Re: Can I change the trace_out.txt file location?
« Reply #3 on: July 14, 2016, 01:37:14 PM »

I'll leave it for education purposes Andrey, if you don't mind.

Please do. seeing how other people create/solve problems is valuable.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Can I change the trace_out.txt file location?
« Reply #4 on: July 14, 2016, 04:13:24 PM »

I'll leave it for education purposes Andrey, if you don't mind.

Please do. seeing how other people create/solve problems is valuable.
If it is interesting for you... The "adventures" aren't ended... Here is continuation, and here is a hope of appearing of decission.