Silverlight UnitTesting does not call TestInitialize

I am using (or trying) to perform unittesting Silverlight.

everything looks good, but the methods associated with the [TestInitialize] attribute are not called before [TestMethod] . Does anyone know a workaround?

here is an example where the BeforeAnyTest method is never called:

  [TestClass] public class TViewModel { protected MockRepository MockRepository { get; set; } /// <summary> /// This is strangely not called automatically before any test /// </summary> [TestInitialize] protected void BeforeAnyTest() { MockRepository = new MockRepository(); } [TestMethod] public void TServerStartupViewModelCtor() { //BeforeAnyTest(); var smsa = MockRepository.StrictMock<IServerManagementServiceAgent>(); ServerStartupViewModel ssvm = new ServerStartupViewModel(smsa); Assert.IsNotNull(ssvm); } } 
+4
source share
1 answer

Try defining it as public instead of protected .:

 [TestInitialize] public void BeforeAnyTest() { MockRepository = new MockRepository(); } 
+10
source

Source: https://habr.com/ru/post/1342129/


All Articles