Hi, I'm developing a Xamarin.Forms application and I want to use Xamarin.UITest with the POP (Page Object Pattern) to test the UI. I read the documentation and had the chance to see a keynote about this tool and this pattern, but I still don't understand which is the correct way to conditionally test the UI. For example, in my test project, I have a Pages
folder and a Tests
folder. In the first one, I put the pages' representations, while in the second one I put the tests I made about these representations. I want to test the entry input when the user tries to log in. So far, I wrote this method inside the TestProject/Pages/LoginPage.cs
file:
public LoginPage EnterCredentialsAndLogin(string email, string password) { if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { ... } else { ... } }
and I test it using this code in the TestProject/Tests/LoginPageTests.cs
file:
[Test] public void TestLoginWithDifferentCredentials() { new LoginPage().EnterCredentialsAndLogin(null, null); new LoginPage().EnterCredentialsAndLogin("", null); new LoginPage().EnterCredentialsAndLogin("email", null); new LoginPage().EnterCredentialsAndLogin("email", ""); new LoginPage().EnterCredentialsAndLogin(null, ""); new LoginPage().EnterCredentialsAndLogin(null, "password"); new LoginPage().EnterCredentialsAndLogin("", "password"); }
Is this an appropriate way to use the POP? Should I use other approaches?