ashutosh
ashutosh

Reputation: 57

Unit Testing in UWP application throws COMException

Here is the setup I used to reproduce my issue:

  1. Create a UWP Library with the one call as follows:

    using namespace Windows::UI::ViewManagement;
    void noop() {
      auto bounds = ApplicationView::GetForCurrentView()->VisibleBounds;
    }
    

    This function uses the ApplicationView to get the screen bounds of the current app instance.

  2. Create another UWP Test App which references the library. Within it's test method, I call the noop() from MyLib.

On running the tests, it fails and throws a Platform::COMException^. Is there something I am missing?

Thanks for your time.

Upvotes: 0

Views: 94

Answers (1)

Nicolas
Nicolas

Reputation: 1

You should probably call the noop() on the UI thread since you are dealing with some UI elements.

You can use [UITestMethod] instead of [TestMethod] in top of your test method implementation.

Upvotes: 0

Related Questions