locked
Unable to run tests on clean installation of Visual Studio 2015 Community RRS feed

  • Question

  • I have clean install of Windows 10 and a clean install of Visual Studio 2015 Community.

    I create a blank Universal Windows Application with File | New | Project | Windows | Universal | Blank App (Uinversal Windows).

    I add a Unit Test project with Add | New Project | Windows | Universal | Unit Test App (Universal Windows).

    I build and run the application, it runs. I run the Test project and it runs, reporting one (blank) test as completing successfully.

    I use Nuget to install mvvmlightlibs and create a Locator class:

    namespace BlankApp1.Services
    {
      public class Locator
      {
        static Locator()
        {
          ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
          SimpleIoc.Default.Register<ViewModel.MainViewModel>();
        }
        public ViewModel.MainViewModel MainViewModel
        {
          get
          {
            return ServiceLocator.Current.GetInstance<ViewModel.MainViewModel>();
          }
        }
      }
    }

    I build and run the application. I run the test(s) and it passes the one test.

    I reference the locator in app.xaml.cs:

      <Application.Resources>
        <services:Locator x:Key="Locator"/>
      </Application.Resources>

    The application runs okay, but attempting to run the tests now gives:

      Failed to initialize client proxy: could not connect to test process .

    I can't find anything that corrects this and so can't use tests and mvvm in the same application.

    Any clues?

    Andrew

    Monday, August 24, 2015 9:02 AM

All replies

  • Hi Andrew,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, August 26, 2015 2:55 AM
  • Hi Andrew,

    How do you define your unit test? Could you please post here the code?

    Thanks.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, August 26, 2015 7:49 AM
  • Hi Vicky,

    The unit test as originally written was:

    namespace UnitTestProject1
    {
      [TestClass]
      public class UnitTest1
      {
        [TestMethod]
        public void TestMethod1()
        {
          UnitTestFailExample.ViewModel.MainViewModel mainVM = new UnitTestFailExample.ViewModel.MainViewModel();
          Assert.AreEqual("Unit Test Fail Example", mainVM.ApplicationName);
        }
      }
    }

    with the MainViewModel of

    namespace UnitTestFailExample.ViewModel
    {
      public class MainViewModel
      {
        public String ApplicationName
        {
          get
          {
            return "Unit Test Fail Example";
          }
        }
      }
    }

    but I notice that if I then comment all the code in TestMethod1 out so that it is just a stub, I still get the "Failed to initialize client proxy: could not connect to test process ." message. It is not the test itself but the addition of the Locator that results in the problem showing.

    Thanks

    Andrew

    Wednesday, August 26, 2015 10:03 AM
  • I am running into the exact same thing.  MVVM Light toolkit.  I comment out my line in App.xaml that defines the view model locator, and all of a sudden my tests are running.
    Sunday, August 30, 2015 4:28 AM
  • I haven't found any way of allowing design-time data and unit testing in the same application. This is making development a bit hard.
    Sunday, August 30, 2015 2:14 PM