Coder Social home page Coder Social logo

microsoft / appcenter-xamarin.forms-gallery-demo Goto Github PK

View Code? Open in Web Editor NEW
11.0 10.0 7.0 435 KB

Demonstration based on this sample, to show how different UI elements can be tested with App Center: https://github.com/xamarin/xamarin-forms-samples/tree/master/FormsGallery

License: MIT License

C# 96.15% Shell 3.85%

appcenter-xamarin.forms-gallery-demo's Introduction

Main branch project build status

  • Android: Build status
  • iOS: Build status

Packages

If the sample hasn't been updated for awhile and hits strange errors, it's highly recommended to try updating the following packages:

  • Xamarin.UITest in the Xamarin.UITest project
  • Xamarin Test Cloud Agent in the iOS project
  • Xamarin.Forms in the iOS & Android project

Please file an issue if there's a problem either updating the packages, or you hit strange errors after hitting them.

FormsGallery Xamarin.UITest sample

This sample displays all the views, cells, layouts, and pages available in Xamarin.Forms, one per page; and some basic Xamarin.UITest interactions with those elements.

General Xamarin.UITest project structure

AppInitializer

This is a fairly standard format for enabling cross-platform Android & iOS testing. It's essentially using the default Visual Studio Mac template for a cross-platform UITest, except for line 35:

Environment.SetEnvironmentVariable("UITEST_FORCE_IOS_SIM_RESTART", "1");

This environment variable is used so that when testing on a local iOS simulator, the app is always restarted. This is required to work around a local testing bug in the current stable version of Xamarin.UITest (at the time of writing this).

Multiple Test Fixtures

Each of these .cs files is a separate Test Fixture, which are named based on the grouped related elements in the underlying Xamarin.Forms app navigation:

  • Cells.cs
  • LayoutsWithMultipleChildren.cs
  • LayoutsWithSingleContent.cs
  • Pages.cs
  • ViewsForEditingText.cs
  • ViewsForPresentation.cs
  • ViewsForSettingValues.cs
  • ViewsThatDisplayCollections.cs
  • ViewsThatInitiateCommands.cs

HelperMethods.cs

This file contains methods which are shared across each and every Test Fixture listed above, to handle common shared logic and/or especially complex testing scenarios.

TestFixture required SetUp method

This includes a required [SetUp] method called "BeforeEachTest()", which is executed before each [Test]: https://github.com/King-of-Spades/appcenter-Xamarin.Forms-Gallery-Demo/blob/main/FormsGallery/FormsGallery.UITest/HelperMethods.cs#L100-L104

OpenPage(string page, int pageType)

  • page - pass a case-sensitive string for Xamarin.UITest to find on the main page of the app. UITest will tap the element to open the page or scroll down on the view if it's not found to see if it appears and then can tap it.
  • pageType - Selects either "C# Pages" or "XAML Pages" in the UI before finding the specific page searched for.

Source: https://github.com/King-of-Spades/appcenter-Xamarin.Forms-Gallery-Demo/blob/main/FormsGallery/FormsGallery.UITest/HelperMethods.cs#L14-L31

SetDatePicker(DateTime date)

This method Invokes native Android & iOS methods on their respective platforms in order to update the DatePicker values.

  • date - Takes a standard "DateTime" value, though the method only works with Month, Day & Year; because those are what the Forms DatePickers are set up to work with.

Source: https://github.com/King-of-Spades/appcenter-Xamarin.Forms-Gallery-Demo/blob/main/FormsGallery/FormsGallery.UITest/HelperMethods.cs#L34-L57

Called by ViewsforSettingValues.cs -> [Test] DatePicker(): https://github.com/King-of-Spades/appcenter-Xamarin.Forms-Gallery-Demo/blob/main/FormsGallery/FormsGallery.UITest/ViewsForSettingValues.cs#L81-L93

SetTimePicker (int hour, int minute, bool am)

Unlike SetDatePicker this method can't directly accept a DateTime, because it would require setting a day, month, & year when only the hour, minute & am/pm values are actually needed. This is worked around by using DateTime.Now within the method itself so that it can be handled in a somewhat similar fashion to the companion SetDatePicker method.

Called by ViewsforSettingValues.cs -> [Test] TimePicker(): https://github.com/King-of-Spades/appcenter-Xamarin.Forms-Gallery-Demo/blob/main/FormsGallery/FormsGallery.UITest/ViewsForSettingValues.cs#L95-L107

appcenter-xamarin.forms-gallery-demo's People

Contributors

king-of-spades avatar microsoftopensource avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.