title: Testing a Windows 8 Store App with NUnit
body: <p>I'm currently working on a Windows Store Application (Windows 8) for a class and I'm having problems getting my NUnit tests to run.</p>
  
  <p>My Solution/Project setup looks like the following:</p>
  
  <ul>
  <li><p>TheMetroApp.sln</p>
  
  <ul>
  <li>SQLite-net.csproj - Class Library (Windows Store Apps). Files are pulled from NuGet.</li>
  <li>DataModel.csproj - Class Library (Windows Store Apps)</li>
  <li>UnitTests.csproj - Unit Test Library (Windows Store Apps). NUnit framework is pulled from NuGet.</li>
  <li>TheMetroApp.csproj - A project file which was pulled from one of the Windows SDK examples.</li>
  </ul></li>
  <li><p>Misc. Dependencies and Utilities</p>
  
  <ul>
  <li>Windows 8 Pro RTM/Visual Studio 2012 RTM</li>
  <li>ReSharper 7</li>
  <li>NUnit 2.6.1</li>
  <li>SQLite (Set up per the instructions <a href="http://timheuer.com/blog/archive/2012/08/07/updated-how-to-using-sqlite-from-windows-store-apps.aspx">here</a>)</li>
  </ul></li>
  </ul>
  
  <p>UnitTests is dependent upon and references DataModel. DataModel is dependent upon and references SQLite-net. The only thing I have added to the UnitTests project is a single class containing some stub NUnit unit tests. As far as I can tell, these are set up correctly:</p>
  
  <pre><code>[TestFixture]
  public class TaskSourceTests
  {
      #region Private Class Members
  
      private ITaskSource _taskSource;
      private String _dbPath;
  
      #endregion
  
      #region Testing Infrastructure
  
      [SetUp]
      public void SetUp()
      {
          // This part makes NUnit/ReSharper have problems.
          _dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "UnitTestDatabase.sqlite");
      }
  
      #endregion
  
      #region Misc. CRUD stuff
  
      [Test]
      public void CreateTaskTest()
      {
          // Save the task.
          Task task = new Task( "Some Task", "lol.", DateTime.Now, false );
          _taskSource.Save( task );
  
          // Confirm that it is in the task db.
          using( SQLiteConnection db = new SQLiteConnection( _dbPath ) )
          {
              const String query = "SELECT * FROM Task WHERE Id = ?";
              IList&lt;Task&gt; results = db.Query&lt;Task&gt;( query, task.Id );
              Assert.True( results.Contains( task ) );
          }
      }
  
      // ...and so on [but with stubs that are basically Assert.Fail( "" )].
  
      #endregion
  }
  </code></pre>
  
  <p>TheMetroApp is one of the Windows 8 SDK sample projects, but with some custom XAML forms thrown in. I'm not having any problems with this project.</p>
  
  <p><em>My issue is that none of the Unit Test runners that I have tried to use are working.</em></p>
  
  <p>When I try to use the official NUnit x86 Test runner (version 2.6.1), my tests fail due to certificate related issues <a href="http://social.msdn.microsoft.com/Forums/en-US/toolsforwinapps/thread/449635cd-6aad-4d89-95a7-be7444d48f98">(see here)</a>:</p>
  
  <pre><code>UnitTests.TaskSourceTests.CreateTaskTest:
  SetUp : System.InvalidOperationException : The process has no package identity. (Exception from HRESULT: 0x80073D54)
  </code></pre>
  
  <p>ReSharper's NUnit test runner fails for the exact same reason. Unfortunately, it doesn't look like there is currently a workaround for that.</p>
  
  <p>I have also tried using the test runner built into Visual Studio 2012 (through the <a href="http://www.nunit.org/index.php?p=vsTestAdapter&amp;r=2.6">NUnit Visual Studio Test Adapter</a>). When I try to run my tests using "Run All", I get the following output:</p>
  
  <pre><code>------ Run test started ------
  Updating the layout...
  
  Checking whether required frameworks are installed...
  
  Registering the application to run from layout...
  
  Deployment complete. Full package name: "GibberishAndStuff"
  
  No test is available in C:\Projects\project-name\ProjectName\UnitTests\bin\Debug\UnitTests.dll. Make sure that installed test discoverers &amp; executors, platform &amp; framework version settings are appropriate and try again.
  ========== Run test finished: 0 run (0:00:09.4873768) ==========
  </code></pre>
  
  <p>Something strange I have noticed is that if I select a specific test in the Test Explorer and tell it to run, I get a slightly different error message:</p>
  
  <pre><code>Could not find test executor with URI 'executor://nunittestexecutor/'.  Make sure that the test executor is installed and supports .net runtime version 4.0.30319.18010.
  </code></pre>
  
  <p>This is kind of perplexing because I have the NUnit Test Adapter installed. I'm not seeing anything similar to my issue on the launchpad page for the test adapter.</p>
  
  <p>I'm not really sure where I should proceed from here. If this doesn't work I don't mind reworking my project to use xUnit.net, Microsoft's unit testing framework or something else. It would be pretty awesome if I could get NUnit working though.</p>
  
  <p>Thanks!</p>