Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

DeviceTests: Added Traits to headless runner #128

Merged
merged 7 commits into from
Mar 29, 2018

Conversation

Redth
Copy link
Member

@Redth Redth commented Mar 28, 2018

Description of Change

Adds the ability to filter device tests by traits.

For starters, the DeviceType trait is now excluded based on if the test runner is on a physical or virtual device (so if we're running on Virtual, all tests marked with a DeviceType trait of Device will be skipped (and vice versa).

We can add more traits as needed.

PR Checklist

  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Updated documentation (see walkthrough)

This gets the Virtual/Physical DeviceType trait we will want to exclude (so it’s the opposite of the currently executing device type).
@Redth Redth requested a review from mattleibow March 28, 2018 20:18
@Redth Redth added the awaiting-review This PR needs to have a set of eyes on it label Mar 28, 2018
@Redth Redth added this to the Preview-1 milestone Mar 28, 2018
@Redth Redth changed the title Devicetests traits DeviceTests: Added Traits to headless runner Mar 28, 2018
mattleibow
mattleibow previously approved these changes Mar 28, 2018
@@ -8,6 +11,9 @@ internal static class DeviceTypes
{
public const string Physical = "Physical";
public const string Virtual = "Virtual";

internal static string ToExclude =>
DeviceInfo.DeviceType == RuntimeDeviceType.Physical ? Virtual : Physical;
Copy link
Contributor

Choose a reason for hiding this comment

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

Something about this wording/idea is a bit annoying to my mind, but I can't really think of a better/different way right now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah :( I agree...

{
var filters = new List<XUnitFilter>
{
new XUnitFilter(Traits.DeviceType, Traits.DeviceTypes.ToExclude, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to address this in future if we ever have to add more filters - maybe find a way to sync them up or something. We just have to remember to do this for each platform 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.

Yeah I suppose we could have a shared helper method to GetSharedFilters()

@mattleibow
Copy link
Contributor

mattleibow commented Mar 28, 2018

@Redth The style Cop got you! 😉

@jamesmontemagno jamesmontemagno merged commit 3024d8b into xamarin:master Mar 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting-review This PR needs to have a set of eyes on it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants