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

Add a unit test project #1444

Merged
merged 3 commits into from
Feb 7, 2024
Merged

Add a unit test project #1444

merged 3 commits into from
Feb 7, 2024

Conversation

kmahone
Copy link
Member

@kmahone kmahone commented Feb 6, 2024

This adds a set of unit tests to WinUIGallery.

The initial set of tests are mostly just to serve as a demonstration of how to write tests in MSTest for WinUI. But as new features are added to WinUI we can optionally write them in a more unit-testable way and add new tests here. Unit tests have the advantage of being quicker and more reliable that UI Interaction tests which is where we are getting most of the coverage now.

I've also updated the Azure Pipeline job to execute the unit tests as part of the build.

This PR updates the version of WinAppSDK from 1.4 to 1.5 Preview1. Once 1.5.0 stable is released we should update to that.

@kmahone kmahone requested a review from karkarl February 6, 2024 22:36
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<ResourceDictionary.ThemeDictionaries>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these resources pasted over from WinUI Gallery? If not all resources are required, may be worth it to clean it up.

displayName: 'List contents of ArtifactStagingDirectory and DefaultWorkingDirectory'

- task: VSTest@2
displayName: 'Run Unit Tests'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth it to label it as "Run Sample Unit Tests" since these mostly serve as a demonstration rather than an actual test.

@marcelwgn
Copy link
Collaborator

I'm wondering if having unit tests also warrants having a tests and src folder where the projects are located similar to a lot of other .Net projects. What do you folks think?

@@ -13,7 +13,7 @@

namespace AppUIBasics
{
class IdleSynchronizer
public class IdleSynchronizer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this related to the unit tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At one point I was using it from one of the unit tests. I'll leave it as it is.

@@ -0,0 +1,65 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need a certificate for the unit types project?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not creating an msix so we don't need the cert.

@kmahone kmahone merged commit bc61464 into main Feb 7, 2024
2 checks passed
@karkarl karkarl deleted the user/kmahone/unittests1 branch February 12, 2024 23:51
karkarl pushed a commit that referenced this pull request Jul 15, 2024
This adds a set of unit tests to WinUIGallery.

The initial set of tests are mostly just to serve as a demonstration of
how to write tests in MSTest for WinUI. But as new features are added to
WinUI we can optionally write them in a more unit-testable way and add
new tests here. Unit tests have the advantage of being quicker and more
reliable that UI Interaction tests which is where we are getting most of
the coverage now.

I've also updated the Azure Pipeline job to execute the unit tests as
part of the build.

This PR updates the version of WinAppSDK from 1.4 to 1.5 Preview1. Once
1.5.0 stable is released we should update to that.

---------

Co-authored-by: Keith Mahoney <you@example.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants