Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow async test methods for UITestMethod on UWP and WinUI #5297

Merged
merged 18 commits into from
Mar 31, 2025

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Mar 22, 2025

Fixes #5306

@marcelwgn
Copy link

Uhm, how does this address #740? The former is about being able to use datarows with UITests, this PR on the other hand allows using async on tests right?

@Youssef1313
Copy link
Member Author

Youssef1313 commented Mar 24, 2025

@marcelwgn The original issue description is inaccurate. Based on the comments/discussions there, the real issue is really just UITestMethodAttribute deadlocking. Using parameterized tests does not require DataTestMethodAttribute, and so we should not introduce UIDataTestMethodAttribute as it doesn't serve any purpose.

@marcelwgn
Copy link

So the following test should work then?

[UITestMethod]
[DataRow(0)]
[DataRow(1)]
[DataRow(2)]
public void TestMethod2(int index)
{
    var grid = new Grid
    {
        MinWidth = index
    };

    grid.UpdateLayout();

    Assert.AreEqual(index, grid.ActualWidth);
}

Because when I run it in Visual Studio, I get the following issue:

    Cannot run test method 'App8.UnitTest1.TestMethod2': Test data doesn't match method parameters. Either the count or types are different.
Test expected 1 parameter(s), with types 'Int32',
but received 0 argument(s), with types ''.

The thread in that issue evolved to providing a workaround to that missing capability using async tests that would essentially implement the behaviour that UITestMethod should support, but that requires async which is not supported. I disagree that the original issue description is misleading, the above sample does not work so there still is no support for this. ALlowing async would just allow for a workaround to work.

@Youssef1313
Copy link
Member Author

It's supposed to work. I'll check why it doesn't work, but that wasn't what I understood from the follow-up comments.

@Youssef1313
Copy link
Member Author

@marcelwgn This should be working if you are using the latest MSTest. I could repro only with really old versions of MSTest that are not supported.

@Youssef1313 Youssef1313 changed the title Add TestMethodAttribute.ExecuteAsync Allow async test methods for UITestMethod on UWP and WinUI Mar 25, 2025
@Youssef1313 Youssef1313 marked this pull request as ready for review March 25, 2025 07:09
@Youssef1313 Youssef1313 requested a review from nohwnd March 25, 2025 08:50
@Youssef1313 Youssef1313 merged commit 68d9c65 into microsoft:main Mar 31, 2025
8 checks passed
@Youssef1313 Youssef1313 deleted the uwp-deadlock branch March 31, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support async test methods for UITestMethodAttribute (for UWP/WinUI)
3 participants