title: Test Method 'X' threw exception: System.InvalidOperationException: Mapper not initialized. Call Initialize with appropriate configuration
body: <p>Here is the code for the method that I'm developing the unit test for:</p>
  
  <pre><code>public ActionResult ItemsListing()
  {
      var itemsList = itemsRepository.GetItems(true);
  
      if (itemsList.Count() &gt; 0)
      {
          var itemsListVMs = Mapper.Map&lt;IEnumerable&lt;Item&gt;, IEnumerable&lt;itemsListingViewModel&gt;&gt;(itemsList);
          return View(itemsListVMs);
      }
      else
      {
          return RedirectToAction("Home");
      }
  
  }
  </code></pre>
  
  <p>Following is the code from the mapping configuration file:</p>
  
  <pre><code>public static class MappingConfig
  {
      public static void RegisterMaps()
      {
          Mapper.Initialize(config =&gt;
          {
              config.CreateMap&lt;Item, itemsListingViewModel&gt;();
          });
      }
  }
  </code></pre>
  
  <p>And I have initialized mapper in the <code>Application_Start()</code> event of the <code>Global.asax</code> as below:</p>
  
  <pre><code>MappingConfig.RegisterMaps();
  </code></pre>
  
  <p>Below is the simple test method that I'm trying to run:</p>
  
  <pre><code>[TestMethod]
  public void ItemsListing()
  {
      HomeController controller = new HomeController();
  
      ViewResult result = controller.ItemsListing() as ViewResult;
  
      Assert.IsNotNull(result);
  }
  </code></pre>
  
  <p>It works fine when I simply run the application. But when I try to run the unit test method, it shows the mentioned error message. Can anyone help me to get over this issue? Thanks!</p>