Hey all, I've got a Silverlight unit test that I'm using as a smoke test to load all of my views. Unfortunately if it hits one with an exception, the test ends. I've got a loop that goes through each view and I'd like it to just log the failure and continue with the next view.
Despite putting a try catch, the test still exits with a null exception on the first bad view. Is there any way to make it actually hit my catch rather than fail the unit test. Not sure I want the test to expect a unit test (ie I know you can pass the test on certain exceptions). Simplified a little to show the code structure without confusion. None of the catch's get hit despite the exeptions happening inside the try block. [TestMethod] [Asynchronous] [Description("Navigates to each view.")]public void AllViews_NavigateToAllViewsSequentially_IsDisposed() { // Do some setup // wait for shell to be loaded into testpanel EnqueueConditional(() => IsShellLoaded); foreach (var view in views) { try { IViewModel viewModel = null; if (view != null) { if (view.Name.Contains("Summary")) { EnqueueCallback(() => { try { var uri = ResourceRegistry.GetResourceValue(view.Name); var regionManager = this.UnityContainer.Resolve<IRegionManager>(); regionManager.RequestNavigate(RegionNames.MainContentRegion, new Uri(uri, UriKind.Relative), (args) => { // do stuff with the view and viewmodel }); } catch (Exception e) { Debug.WriteLine(e.Message); } }); EnqueueConditional(() => viewModel.IsInitialised); EnqueueCallback(() => { Debug.WriteLine("unit test for {0} viewmodel run", viewModel.ToString()); Assert.IsTrue(viewModel.IsInitialised, "viewmodel {0} was not initialise", viewModel.ToString()); }); } } } catch (Exception e) { Debug.WriteLine(e.Message); } } EnqueueTestComplete(); }
_______________________________________________ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight