Capturing standart output

Feb 22, 2011 at 4:39 PM

Hi All,

is there an easy way to capture standard output and include it into the log files created by nbehave msbuild task?

or alternatively some mechanism for directly writing into nbehave log file from the action steps?

Lior

Coordinator
Feb 23, 2011 at 12:14 PM

Unfortunately there is no easy way of doing this right now.  You could use Console.WriteLine in your action steps and then get  your build process to direct the MSBuild output to a log file.

Can I please ask why you are wanting to do this?  This isn't a requirement that anybody on the NBehave dev team has come across before and so we are keen to understand your use case.

Cheers,
John 

Feb 23, 2011 at 1:22 PM

Actually that what i wanted to do, however I don't know of quick way to do it.

I couldn't find a way to tell msbuild to redirect the console output of the nbehave task into a file. Now that you mention it it sounds reasnoable that there should be such a way using some coomand line argument to msbuild.

I'm using console.writeline to output  data that will help  get a better understanding of what goes inside my steps and help me during debugging. 

specifically I log inside exceptions in order to understand what goes wrong (when things goes wrong) and I'm looking for a clean mechanism to include them into the build output so far i didn't find a good way to include them inside the nbehave report.

I think that part of the problem is that im developing a visual studio add-in. this means that the tests are done using the automation model which basically doesn't wok inside a debugger, and if thats not enough I'm encountering specific issues only when run as part of the build server so a simple debug (which would probably solve the problem real easy) is not really an option.

 I think that it would probably be useful to have some sort of mechanism to log stuff into nbehave output file.

does this make sense?

 

Coordinator
Feb 23, 2011 at 3:28 PM

Directing MSBuild output to a file is pretty easy from the command line.  All you need to do is use the > redirection operator.  So to log the output in a file "out.txt" your command would be something like:

msbuild build.proj > out.txt

I think it's reasonable that NBehave could setup a debug listener, so that Debug.WriteLine calls from your tests would get logged in the NBehave output log.  If this is something that would be useful to you then please open an issue on the Google code site.  Of course, I can't make any real promises about when the feature will get released, but I can tell you that it will be sooner if you also upload a patch.  :-)

Cheers,
John 

Feb 23, 2011 at 5:10 PM

Actually that would probably work.

I was running inside a team city server and while my initial instinct told me I cant do that now that i think of it that should probably be possible. Thank you for opening my eyes. 

Ill open a new issue. and i hear you about the patch. However ill need to take a rain check on this.

too much going on at the moment.(sorry)