-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Test TextBox with a TextBoxMask.Mask and x:Bind #3512
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
Conversation
|
Thanks RosarioPulella for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
|
|
|
Changed the base of this PR to the other branch for now so it's easier to review/comment on until that one gets merged, then we can switch back. |
michael-hawker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to make sure we use this PR to set ourselves up for adding more tests as we move forward from here! 🙂
| <Compile Include="MainPage.xaml.cs"> | ||
| <DependentUpon>MainPage.xaml</DependentUpon> | ||
| </Compile> | ||
| <Compile Include="Pages\SimpleTest.xaml.cs"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@azchohfi can we use the SDK Extras to switch to the new-style project here? Don't want to get into merge problems in the future with multiple-tests being written.
Otherwise we can try using the glob syntax instead?
| <TextBlock x:Name="textBlock"/> | ||
| <Frame x:Name="navigationFrame" /> | ||
|
|
||
| <StackPanel Orientation="Horizontal" Grid.Row="1" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I don't like the use of the buttons here to control the page navigation, we should build this into the infrastructure itself. So the MainPage has a function of understanding how to switch tasks and can evaluate a string and navigate to that page based on reflection or something, similar to how we navigate within the SampleApp currently:
| } | ||
|
|
||
| [TestMethod] | ||
| public void TestTextBoxMaskBinding_Property() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely want to figure out how we split these into multiple files as well, so we can have multiple test cases per test page. i.e. we can have a test page using the component with a setup or two, and then have multiple smaller test methods to run against it.
Though ideally, we figure out how to manage this without tearing down and re-opening the app each time?
@azchohfi as commented on the other PR, do you know how we'd structure this here or have suggestions?
| Verify.AreEqual(newValue, textBox.GetText()); | ||
| } | ||
|
|
||
| private static void OpenTest(string name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, so this method should be integrated into the test-harness itself and know how to communicate with the MainPage in order to switch the page in the frame. We don't want to have to rely on adding more custom buttons and things to the main test page in order to do this.
As mentioned in the other PR I think the use of a custom Attribute could be handy if we could make that work. i.e.
[TestMethod]
[TestXamlFile("TextBoxMaskTestPage")]
public void TestTextBoxMaskBinding_Property()
{The test harness before each test would read the attribute on it to grab the type name of the page to load, then we'd have to send the test app a message to load that page, and then execute the test.
Not sure if we would need an intermediary UI piece, use the clipboard, or go as heavy as an AppService to do this. Looks like in WinUI they just manipulate the UI similar to how you did it here, just more generally with a command: https://github.com/microsoft/microsoft-ui-xaml/blob/master/test/TestAppUtils/NavigateToTestCommand.cs#L12
And they use their TestSetupHelper to manually control the page at the start of each test: https://github.com/microsoft/microsoft-ui-xaml/blob/master/dev/TabView/InteractionTests/TabViewTests.cs#L49
@azchohfi thoughts? Should we just copy the setup WinUI has or should we try and improve upon this somehow with an attribute on the test method itself to control this?
I'm guessing it is easier if the idea is to better introp to WinUI that we more closely follow their patterns? @ranjeshj any preferences on if we experiment or try to more closely align? Has the current WinUI system been working well or have you been looking to changing it in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I left out that part of why I want to try and simplify these connections is to make it as straight-forward and easy for developers to add integration tests so that we can ensure adding them isn't a big burden to our community.
I think if we could introduce a new attribute based system here, it'd give developers the flexibility to re-use a page easily or setup multiple pages for different scenarios, eh?
It also makes each test easier to maintain and understand as all the test harness initialization is abstracted to the attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically we'd set something up like this to grab the attribute for the base of our test system:
public TestContext TestContext { get; set; }
[TestInitialize]
public void TestInitialize()
{
Debug.WriteLine("Running Test: " + TestContext.TestName);
var currentlyRunningMethod = GetType().GetMethod(TestContext.TestName);
var descriptionAttributes = currentlyRunningMethod.GetCustomAttributes(typeof(DescriptionAttribute), true) as System.Collections.Generic.IEnumerable<DescriptionAttribute>;
var firstOne = descriptionAttributes.FirstOrDefault();
if (firstOne != null)
{
Debug.WriteLine("Description: " + firstOne.Description);
}
}This is just grabbing a description attribute, but would work the same for our custom attribute and use that info to load the appropriate page in the Test App via test control commands as done currently or some other channel (AppService?).
In either case, I think we should have the test app load the requested page on demand vs. trying to determine all the pages ahead of time and load them at the start of the app. I think this would help with the test app starting time? Which would help if you're picking specific tests to run from VS, right?
Thoughts?
|
Sorry @RosarioPulella looks like my change I did forced this to close unexpectedly. Can you rebase your branch on top of master and then try force-pushing this branch to see if we can re-open the PR after that? |
|
@michael-hawker Just rebasing did not fix the PR. I would need to change what branch the PR is targeting, and GitHub does not seem to let me do that. Should I open a new PR? I'll make sure to reference all the requested changes. |
Add UI tests for
TextBoxwith aTextBoxMask.Maskandx:BindUses WinUI Test Infrasttcure from #3482 to test the fix from #3338 for #3335.
PR Type
What kind of change does this PR introduce?
What is the current behavior?
No UI Tests for TextBoxMask
What is the new behavior?
Given a
TextBoxwith aMaskset and itsTextbound to a C# property usingx:Bind. It tests if the text in theTextBoxupdates when that property is updated.PR Checklist
Please check if your PR fulfills the following requirements:
[ ] Pull Request has been submitted to the documentation repository instructions. Link:Other information
Does not test #3514