title: Is it bad to add code just for unit testing?
body: <p>I am writing a class to help me unit test my code.  It looks like this:</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Wrapper for the LogManager class to allow us to stub the logger
  /// &lt;/summary&gt;
  public class Logger
  {
      private static ILogger _logger = null;
  
      /// &lt;summary&gt;
      /// This should be called to get a valid logger.
      /// &lt;/summary&gt;
      /// &lt;returns&gt;A valid logger to log issues to file.&lt;/returns&gt;
      public static ILogger GetLogger()
      {
          if (_logger == null)
            _logger = LogManager.GetLogger("logger");
  
          return _logger;
      }
  
      /// &lt;summary&gt;
      /// This is used by unit tests to allow a stub to be used as a logger.
      /// &lt;/summary&gt;
      /// &lt;param name="logger"&gt;&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      public static ILogger GetLogger(ILogger logger)
      {
          _logger = logger;
          return _logger;
      }
  }
  </code></pre>
  
  <p>The second method is for unit testing only.  I never intend to have it called in my production code.</p>
  
  <p>Is this bad practice?  Should I find another way that does not do this?</p>