I could not re-open this:
https://github.com/Windows-XAML/Template10/issues/178
so I created new issue. Problem still exists and is related with Template10. Please provide solution.
@labretrox could you share with me what is not working?
I've seen this too. It is failing in the following scenario:
As the test loads, you get an error this exception:
"Cannot deserialize XBF metadata type list as 'BootStrapper' was not found in namespace 'Template10.Common'. [Line: 0 Position: 0]"
These steps work fine in the basic Blank project that comes with VS. As a way around this behavior, I moved my source code and xaml files to a class library that is referenced in the app and test projects. The app project just holds App.xaml & cs, Assets folder, Styles folder, and appx manifest.
Is your universal test app of the same type as the universal app? I came across this thread trying to debug a similar issue while using Prism...
App.xaml.cs for the UAP using Prism had this:
sealed partial class App : PrismUnityApplication
which is a departure from the default:
sealed partial class App : Application
A newly created unit test app will also inherit from Application.
Looking at the Blank app sample, I see a customized Application class:
sealed partial class App : Template10.Common.BootStrapper
Is the universal testing problem resolved duplicating this class definition into
Template10/Template10 (Tests)/UnitTestApp.xaml.cs
and changing the root of UnitTestApp.xaml from <Application ..../> to <Template10:Bootstrapper xmlns:template10="using:Template10.Common ..../>"?
I also see this issue:
1) Create a Hamburger (Template 10) app.
2) Create a Unit Test App (Universal Windows) in same solution.
3) Reference the Hamburger app from the Unit Test app and then when you run the default test in UnitTest.cs, you get the following:
"A user callback threw an exception. Check the exception stack and inner exception to determine the callback that failed.
========== Run test finished: 0 run (0:00:07.6862905) =========="
Will this be fixed soon as writing unit tests is a must have strategy for us whilst developing our UWP commercial app?
Regarding the last suggestion by @jamesfisher314, I tried changing the class definition of the UnitTestApp to Template10.Common.BootStrapper, but it still produced the run time issue when trying to execute the tests:
A user callback threw an exception. Check the exception stack and inner exception to determine the callback that failed.
========== Run test finished: 0 run (0:00:03.4230976) ==========
Has anyone any other ideas to resolve this?
I'm not certain why this is marked as an enhancement/question. If this problem can't be fixed, Template 10 becomes pretty much impossible to use in a BDD/TDD solution.
I'm hoping there is a quick resolution to the problem, because I've otherwise liked the product.
Hello, for what I found the issue seems not specific to Template10, but arises every time you inherit your App class from a custom class (not Windows.UI.Xaml.Application). In fact, similar issues are open on GitHub for Prism (https://github.com/PrismLibrary/Prism/issues/313) and Caliburn.Micro (https://github.com/Caliburn-Micro/Caliburn.Micro/issues/238). A solution is given by Brian Lagunas for the Prism issue, and consists in decorating the App class (the one that inherits from Template10.Common.BootStrapper) with the Windows.UI.Xaml.Data.Bindable attribute.
If the workaround seems not working at first, try to clean the solution and then build it again, it should work.
In addition, after some testing, I discovered that if you have a ResourceDictionary defined in a xaml file with an x:Class declaration (that's needed if you want to use x:Bind inside the resources defined in the dictionary), you have to apply Bindable attribute to that classes too.
Hi @effpath999, I have just tried your suggestion as below:
[Bindable]
sealed partial class App : Template10.Common.BootStrapper
{ ... }
Rebuilt the solution, but I am still seeing the following error when I execute the unit tests:
------ Run test started ------
Updating the layout...Checking whether required frameworks are installed...
Registering the application to run from layout...
Deployment complete (926ms). Full package name: "XXX"
A user callback threw an exception. Check the exception stack and inner exception to determine the callback that failed.
========== Run test finished: 0 run (0:00:04.1231897) ==========
Is there anything else that I should be doing to get this workaround working?
Hi @SandipAhluwalia, I see from a comment above that you tried changing the class definition of the UnitTestApp to Template10.Common.BootStrapper. So, if you still have that class definition in your unit test app, you have to apply the Bindable attribute both to that class and to the app class of the app you want to test. Or, maybe better, just revert the class of the unit test app to a normal Application class.
Also, if you have any xaml file (other than the pages) with an x:Class attribute defined, you have to apply the Bindable attribute to that class too (in my case I had two resource dictionaries defined in this way).
If this does not work, I fear I can't help more. Honestly I have not had the time to investigate why Bindable attribute should make the trick, I only found the suggestion in the link I posted above and found it worked in my case (with the already mentioned addition about the resource dictionaries files).
Thank you @effpath999 for your help. I finally got it working as per your suggestions :)
Because my App.xaml file contained my ViewModelLocator class for MVVM Light purposes, I had to also decorate that with Bindable attribute:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles\Custom.xaml" />
</ResourceDictionary.MergedDictionaries>
<vm:ViewModelLocator x:Key="Locator" />
</ResourceDictionary>
</Application.Resources>
[Bindable]
public class ViewModelLocator
{...}
So this workaround works for me, so it does suggest this issue isn't specific to Template10 as already discussed, but a general UWP issue.
@effpath999 can you (or anyone) confirm this workaround?
Yes @JerryNixon, I confirm that I was able to run unit tests on a Template10 app with this workaround.
It definitely seems a bug related to how the UWP Unit Tests app works rather than to Template10.
@SandipAhluwalia, nice to know the thing about ViewModelLocator. I am using MVVM Light too with a ViwModelLocator, but I didn't run into the issue because I slightly modified it to return the ViewModel instances via static properties that I call in the code behind of the views, in order to have a compile-time, strongly-typed DataContext that is more x:Bind-friendly, so I didn't have to store a ViewModelLocator instance in the application resources.
Okay, so I'm not exactly sure what I'm supposed to be doing here, but when I change the unit test's application from:
sealed partial class App : Application
to
sealed partial class App : Template10.Common.BootStrapper
I get a number of compilation errors.
Is there something more that should be done here?
@PaulMouchet, you don't have to change the class of the unit test app.
Instead, try to apply the Bindable attribute (Windows.UI.Xaml.Data.Bindable) to the class of the app you want to test (which already inherits from Template10.Common.BootStrapper).
Also, if you have a ViewModelLocator class defined as a resource in your App.xaml file, apply the Bindable attribute to that class too, as described in the latest comment from @SandipAhluwalia.
Hi @PaulMouchet, yes, in the end I only needed to apply the Bindable attribute to 2 classes, my Template10 App class and the ViewModelLocator class. I left my UnitTest App class deriving from Application.
@effpath999, I also use x:Bind too, but like setting the DataContext using the ViewModelLocator for normal run-time binding purposes within the page. Thanks again for your help as it means now we can properly progress at my company using Template10 commercially :)
Thanks!
I haven't tested it out thoroughly yet, but putting the [Bindable] decoration on my view model class seems to have done the trick. I can now include a reference to Template10 in my test application and get a successful test result.
For any other random googlers out there, applying [Bindable] to my resource class worked, but only after I completely cleaned and rebuilt my entire solution. So, if you're struggling, rebuild.
Has anyone been able to _debug_ their unit tests after adding [Bindable] to their application class to address this issue?
This exception is thrown for me:
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at Windows.UI.Xaml.Application..ctor()
at My.WindowsMobile.UI.App..ctor()
at My.WindowsMobile.UnitTest.My_WindowsMobile_UnitTest_XamlTypeInfo.XamlTypeInfoProvider.get_OtherProviders()
at My.WindowsMobile.UnitTest.My_WindowsMobile_UnitTest_XamlTypeInfo.XamlTypeInfoProvider.CheckOtherMetadataProvidersForName(String typeName)
at My.WindowsMobile.UnitTest.My_WindowsMobile_UnitTest_XamlTypeInfo.XamlTypeInfoProvider.GetXamlTypeByName(String typeName)
at My.WindowsMobile.UnitTest.App.GetXamlType(string fullName = "Windows.Foundation.IReference`1<Windows.UI.Xaml.Automation.Peers.AccessibilityView>")
I run into the same issue during debugging. Did you found the solution for this error (Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)))?
Many thanks.
Krisztian
Just to add some additional info about debugging: Although the Catastrophic Failure exception is thrown, it is not fatal. In fact, if you turn off 'Break when this exception type is user-unhandled', the unit test app will continue to run and the tests can be debugged as normal (and the test runner does not hang and can be re-ran without relaunching VS). Any code in the app-under-test's constructor does not get executed due to the exception, but this at least helped me debug some tests that were self-contained. Still not sure of the root cause (I know the Prism team said that UWP testing in this manner is not supported, but VS does support it and it works for apps that dont use a custom Application class, so there must be some way to get it to work).
Hi,
I run into the same issue trying to test my Template 10 app. But, the problem come when I add a reference to the UWP project it's using Template 10.
Error detail when run the tests:
Deployment complete (0:00:01.603). Full package name: "xxxx9927-b827-4b2b-8d3b-23ea8ad697ec_1.0.0.0_x86__rzzbfy5xexxxx"
A user callback threw an exception. Check the exception stack and inner exception to determine the callback that failed.
Any idea/help will be appreciated
Thanks a lot
It's 28.7.2017 and the issue is still well and alive :(
Hi, can I get help on this issue? My App class is decorated with Bindable, I can find any other custom xaml that use x:Class. However I get this very issue when I try to use an xunit project
Still an issue in February 2018... Unit testing in UWP is seriously flawed!
Actually, it is not UWP but, it has to do with template 10, ALL my experimentation works, except when you use it with T10
Most helpful comment
Has anyone been able to _debug_ their unit tests after adding
[Bindable]to their application class to address this issue?This exception is thrown for me: