Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3238512
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:51:44+00:00 2026-05-17T17:51:44+00:00

I vaguely remember reading something somewhere about using Trace.WriteLine over Console.Out.WriteLine in nUnit possibly

  • 0

I vaguely remember reading “something” “somewhere” about using Trace.WriteLine over Console.Out.WriteLine in nUnit possibly in the context of reSharper or TeamCity but I cannot remember the details.

Therefore the question is either in the context of nUnit running separately or within reSharper/TeamCity is there any benefit of using one over the other, what are the differences if any and what would you personally use?

Currently my stand point is Trace.WriteLine not only because I vaguely remember something which I could have dreamt up but that I feel that tracing in a unit test is more of a diagnostics task than an output task.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:51:44+00:00Added an answer on May 17, 2026 at 5:51 pm

    Personally, I am not keen on embedding tracing in unit tests (using either method you mention). If a unit test requires this, it is most likely a sign that your unit test is too complex. If you need to trace logic through the unit test, you should use asserts throughout the test to programmatically check that the expected behaviour is occurring, removing the need for the textual tracing output.

    However, you need to be pragmatic – it is useful to do this sometimes. Using either method (or something else like Debug.WriteLine) is fine, but which one you use does give you some flexibility.

    If you have a lot of tests that output tracing, you can get a lot of tracing output when you run all of your tests in a single run. Within NUnit, you can filter this in the options page:

    NUnit Text Options

    The four options do the following ref:

    • Standard Output: Captures all output written to Console.Error.
    • Error Output: Captures all output written to Console.Error.
    • Trace Output: Captures all output written to Trace or Debug.
    • Log Output: Captures output written to a log4net log. NUnit captures all output at the Error level or above unless another level is specified for the DefaultLogThreshold setting in the configuration file for the test assembly or project.

    By turning off these options, you can individually disable the output of tracing sent to the four different logging methods, enabling you to filter your test tracing.

    I am not aware of any similar setting in ReSharper’s test runner.

    One thing also worth considering is that the text output can have side effects. I recently encountered NUnit crashing because some output contained characters that were illegal in an XML file – NUnit produces one as part of our autobuild.


    EDIT:

    @Bronumski: The only real difference I can see of using one method over another is the way the output is consumed.

    Certain tools will pick up Debug tracing (eg. DebugView) but not Console output. Also, you can disable Trace output at runtime via configuration (in app.config), but not Console output. This will only matter though if you have to decorate real (ie. not test) code with tracing for your tests – logging lots of text at runtime can be costly and so is beneficial if it can be turned off unless you really need it to diagnose something.

    Additionally, when using NUnit, you can selectively turn them off independently of each other if you have too much logging to wade through.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I vaguely remember reading about a programming exercise where objects are drawn on the
I vaguely remember reading about this a couple of years ago, but I can't
I vaguely remember reading somewhere (in MSDN ODBC documentation?) that one application cannot make
I vaguely remember reading a blog entry (written by a well-known blogger I think)
I have a fairly weird 'bug' with a simple query, and I vaguely remember
Being vaguely familiar with the Java world I was googling for a static analysis
I realize this is a ludicrous question for something that takes less than 2
I'm working on a game for the xbox360, using XNA. On the Xbox the
How can I use external defines such as LONG_MIN and LONG_MAX in ARM assembler
When I started as at my first job as software developer I was assigned

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.