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

Commit fbebbfc

Browse files
authored
[Tests]Update to Xamarin.UITest 3.0 and NUnit 3.0 (#6332)
* [UITests]Update to Xamarin.UITest 3.0 * [Tests] Move tests to Xamarin.UITests and NUnit 3.0 * [UITests] Use OneTimeSetUp * suppress CS0436
1 parent f74c684 commit fbebbfc

33 files changed

+164
-121
lines changed

Xamarin.Forms.ControlGallery.iOS/Xamarin.Forms.ControlGallery.iOS.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
<PackageReference Include="Xam.Plugin.DeviceInfo" Version="3.0.2" />
350350
<PackageReference Include="Xamarin.Insights" Version="1.12.3" />
351351
<PackageReference Include="Xamarin.iOS.MaterialComponents" Version="72.2.0.1" />
352-
<PackageReference Include="Xamarin.TestCloud.Agent" Version="0.21.7" />
352+
<PackageReference Include="Xamarin.TestCloud.Agent" Version="0.21.8" />
353353
</ItemGroup>
354354
<ItemGroup>
355355
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla35736.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected override void Init()
4545
#if UITEST && __IOS__
4646
[Test]
4747
[Category(UITestCategories.ManualReview)]
48-
[Ignore]
48+
[Ignore("Fails sometimes")]
4949
public void Bugzilla35736Test()
5050
{
5151
RunningApp.WaitForElement(q => q.Marked("Bugzilla35736Editor"));

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/TestPages/ScreenshotConditionalApp.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,7 @@ public FileInfo Screenshot(string title)
236236

237237
public void SwipeRight()
238238
{
239-
#pragma warning disable 618
240-
_app.SwipeRight();
241-
#pragma warning restore 618
239+
SwipeLeftToRight();
242240
}
243241

244242
public void SwipeLeftToRight(double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
@@ -253,9 +251,7 @@ public void SwipeLeftToRight(string marked, double swipePercentage = 0.67, int s
253251

254252
public void SwipeLeft()
255253
{
256-
#pragma warning disable 618
257-
_app.SwipeLeft();
258-
#pragma warning restore 618
254+
SwipeRightToLeft();
259255
}
260256

261257
public void SwipeRightToLeft(double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/TestPages/TestPages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ namespace Xamarin.Forms.Controls.Issues
696696
[SetUpFixture]
697697
public class IssuesSetup
698698
{
699-
[SetUp]
699+
[OneTimeSetUp]
700700
public void RunBeforeAnyTests()
701701
{
702702
AppSetup.RunningApp = AppSetup.Setup(null);

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@
12511251
<ItemGroup>
12521252
<EmbeddedResource Include="$(MSBuildThisFileDirectory)_TemplateMarkup.xaml">
12531253
<SubType>Designer</SubType>
1254-
<Generator>MSBuild:Compile</Generator>
1254+
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
12551255
</EmbeddedResource>
12561256
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue5801.xaml">
12571257
<SubType>Designer</SubType>

Xamarin.Forms.Core.Android.UITests/Xamarin.Forms.Core.Android.UITests.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
</ItemGroup>
4747
<ItemGroup>
4848
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
49-
<PackageReference Include="NUnit" Version="2.6.4" />
50-
<PackageReference Include="NUnitTestAdapter">
51-
<Version>2.1.1</Version>
52-
</PackageReference>
49+
<PackageReference Include="NUnit" Version="3.12.0" />
5350
<PackageReference Include="Xam.Plugin.DeviceInfo" Version="3.0.2" />
54-
<PackageReference Include="Xamarin.UITest" Version="2.2.7" />
51+
<PackageReference Include="Xamarin.UITest" Version="3.0.0" />
52+
<PackageReference Include="NUnit3TestAdapter">
53+
<Version>3.13.0</Version>
54+
</PackageReference>
5555
</ItemGroup>
5656
<ItemGroup>
5757
<Compile Include="BaseViewContainerRemoteAndroid.cs" />
@@ -87,7 +87,7 @@
8787
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8888
<Target Name="_CopyXamarinUITestFiles" AfterTargets="Build">
8989
<ItemGroup>
90-
<_XamarinUITestFiles Include="$(NuGetPackageRoot)Xamarin.UITest\%(Version)\**" Condition="@(PackageReference -> '%(Identity)') == 'Xamarin.UITest'" InProject="False" />
90+
<_XamarinUITestFiles Include="$(NuGetPackageRoot)Xamarin.UITest\%(Version)\**" Condition="@(PackageReference -&gt; '%(Identity)') == 'Xamarin.UITest'" InProject="False" />
9191
</ItemGroup>
9292
<Copy SourceFiles="@(_XamarinUITestFiles)" DestinationFolder="$(SolutionDir)packages\Xamarin.UITest.AnyVersion\%(RecursiveDir)" ContinueOnError="true" Retries="0" />
9393
</Target>

Xamarin.Forms.Core.UITests.Shared/BaseTestFixture.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal abstract class BaseTestFixture
1717

1818
public static AppRect ScreenBounds { get; set; }
1919

20-
[TestFixtureTearDown]
20+
[OneTimeTearDown]
2121
protected virtual void FixtureTeardown()
2222
{
2323
}
@@ -45,7 +45,7 @@ public void EnsureMemory()
4545
[SetUp]
4646
protected virtual void TestSetup()
4747
{
48-
EnsureMemory();
48+
//EnsureMemory();
4949
}
5050

5151
[TearDown]
@@ -55,9 +55,7 @@ protected virtual void TestTearDown()
5555

5656
protected abstract void NavigateToGallery();
5757

58-
#pragma warning disable 618
59-
[TestFixtureSetUp]
60-
#pragma warning restore 618
58+
[OneTimeSetUp]
6159
protected virtual void FixtureSetup()
6260
{
6361
ResetApp();
@@ -111,7 +109,6 @@ protected void ResetApp()
111109
}
112110
}
113111
}
114-
115112
#if UITEST
116113

117114
namespace Xamarin.Forms.Core.UITests
@@ -121,7 +118,7 @@ namespace Xamarin.Forms.Core.UITests
121118
[SetUpFixture]
122119
public class CoreUITestsSetup
123120
{
124-
[SetUp]
121+
[OneTimeSetUp]
125122
public void RunBeforeAnyTests()
126123
{
127124
LaunchApp();
@@ -138,4 +135,4 @@ public static void LaunchApp()
138135
}
139136
}
140137

141-
#endif
138+
#endif

Xamarin.Forms.Core.UnitTests/AnimationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class AnimationTests : BaseTestFixture
88
{
99
[Test]
1010
//https://bugzilla.xamarin.com/show_bug.cgi?id=51424
11-
public async void AnimationRepeats()
11+
public async Task AnimationRepeats()
1212
{
1313
var box = new BoxView();
1414
Assume.That(box.Rotation, Is.EqualTo(0d));

Xamarin.Forms.Core.UnitTests/BindingUnitTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ public void GetterMissingTwoWay()
15881588
Assert.That (() => bindable.SetBinding (MockBindable.TextProperty, new Binding ("Text2")), Throws.Nothing);
15891589
Assert.That (bindable.Text, Is.EqualTo (MockBindable.TextProperty.DefaultValue));
15901590
Assert.That (log.Messages.Count, Is.EqualTo (1), "An error was not logged");
1591-
Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
1591+
Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
15921592
"Text2",
15931593
"Xamarin.Forms.Core.UnitTests.BindingUnitTests+DifferentViewModel",
15941594
"Xamarin.Forms.Core.UnitTests.MockBindable",
@@ -1607,7 +1607,7 @@ public void BindingAppliesAfterGetterPreviouslyMissing()
16071607
Assert.That (bindable.Text, Is.EqualTo ("Foo"));
16081608

16091609
Assert.That (log.Messages.Count, Is.Not.GreaterThan (1), "Too many errors were logged");
1610-
Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
1610+
Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
16111611
"Text",
16121612
"Xamarin.Forms.Core.UnitTests.BindingUnitTests+EmptyViewModel",
16131613
"Xamarin.Forms.Core.UnitTests.MockBindable",
@@ -1621,7 +1621,7 @@ public void SetterMissingTwoWay()
16211621
Assert.That (() => bindable.SetBinding (MockBindable.TextProperty, new Binding ("Text")), Throws.Nothing);
16221622

16231623
Assert.That (log.Messages.Count, Is.EqualTo (1), "An error was not logged");
1624-
Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
1624+
Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
16251625
"Text",
16261626
"Xamarin.Forms.Core.UnitTests.BindingUnitTests+DifferentViewModel",
16271627
"Xamarin.Forms.Core.UnitTests.MockBindable",
@@ -1637,7 +1637,7 @@ public void PrivateSetterTwoWay()
16371637
Assert.That (() => bindable.SetBinding (MockBindable.TextProperty, new Binding ("PrivateSetter")), Throws.Nothing);
16381638

16391639
Assert.That (log.Messages.Count, Is.EqualTo (1), "An error was not logged");
1640-
Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
1640+
Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
16411641
"PrivateSetter",
16421642
"Xamarin.Forms.Core.UnitTests.BindingUnitTests+DifferentViewModel",
16431643
"Xamarin.Forms.Core.UnitTests.MockBindable",
@@ -1646,7 +1646,7 @@ public void PrivateSetterTwoWay()
16461646
Assert.That (() => bindable.SetValueCore (MockBindable.TextProperty, "foo"), Throws.Nothing);
16471647

16481648
Assert.That (log.Messages.Count, Is.EqualTo (2), "An error was not logged");
1649-
Assert.That (log.Messages[1], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
1649+
Assert.That (log.Messages[1], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
16501650
"PrivateSetter",
16511651
"Xamarin.Forms.Core.UnitTests.BindingUnitTests+DifferentViewModel",
16521652
"Xamarin.Forms.Core.UnitTests.MockBindable",
@@ -1660,7 +1660,7 @@ public void PropertyNotFound()
16601660
Assert.That (() => bindable.SetBinding (MockBindable.TextProperty, new Binding ("MissingProperty")), Throws.Nothing);
16611661

16621662
Assert.That (log.Messages.Count, Is.EqualTo (1), "An error was not logged");
1663-
Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
1663+
Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
16641664
"MissingProperty",
16651665
"Xamarin.Forms.Core.UnitTests.MockViewModel",
16661666
"Xamarin.Forms.Core.UnitTests.MockBindable",
@@ -1688,7 +1688,7 @@ public void PropertyNotFoundChained()
16881688
Assert.That (() => bindable.SetBinding (MockBindable.TextProperty, new Binding ("Model.MissingProperty")), Throws.Nothing);
16891689

16901690
Assert.That (log.Messages.Count, Is.EqualTo (1), "An error was not logged");
1691-
Assert.That (log.Messages[0], Is.StringContaining (String.Format (BindingExpression.PropertyNotFoundErrorMessage,
1691+
Assert.That (log.Messages[0], Does.Contain(String.Format (BindingExpression.PropertyNotFoundErrorMessage,
16921692
"MissingProperty",
16931693
"Xamarin.Forms.Core.UnitTests.BindingBaseUnitTests+ComplexMockViewModel",
16941694
"Xamarin.Forms.Core.UnitTests.MockBindable",

Xamarin.Forms.Core.UnitTests/CellTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using NUnit.Framework;
22
using System;
3+
using System.Threading.Tasks;
34

45
namespace Xamarin.Forms.Core.UnitTests
56
{
@@ -153,7 +154,7 @@ public void RenderHeightINPCFromParent()
153154
}
154155

155156
[Test]
156-
public async void ForceUpdateSizeCallsAreRateLimited()
157+
public async Task ForceUpdateSizeCallsAreRateLimited()
157158
{
158159
var lv = new ListView { HasUnevenRows = true };
159160
var cell = new ViewCell { Parent = lv };
@@ -172,7 +173,7 @@ public async void ForceUpdateSizeCallsAreRateLimited()
172173
}
173174

174175
[Test]
175-
public async void ForceUpdateSizeWillNotBeCalledIfParentIsNotAListViewWithUnevenRows ()
176+
public async Task ForceUpdateSizeWillNotBeCalledIfParentIsNotAListViewWithUnevenRows ()
176177
{
177178
var lv = new ListView { HasUnevenRows = false };
178179
var cell = new ViewCell { Parent = lv };

Xamarin.Forms.Core.UnitTests/GeocoderUnitTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Xamarin.Forms.Core.UnitTests
1111
public class GeocoderUnitTests : BaseTestFixture
1212
{
1313
[Test]
14-
public async void AddressesForPosition ()
14+
public async Task AddressesForPosition ()
1515
{
1616
Geocoder.GetAddressesForPositionFuncAsync = GetAddressesForPositionFuncAsync;
1717
var geocoder = new Geocoder ();
@@ -26,7 +26,7 @@ async Task<IEnumerable<string>> GetAddressesForPositionFuncAsync (Position posit
2626
}
2727

2828
[Test]
29-
public async void PositionsForAddress () {
29+
public async Task PositionsForAddress () {
3030
Geocoder.GetPositionsForAddressAsyncFunc = GetPositionsForAddressAsyncFunc ;
3131
var geocoder = new Geocoder ();
3232
var result = await geocoder.GetPositionsForAddressAsync ("quux");

Xamarin.Forms.Core.UnitTests/MotionTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ protected override void DisableTimer ()
6161
[TestFixture]
6262
public class MotionTests : BaseTestFixture
6363
{
64-
[TestFixtureSetUp]
64+
[OneTimeSetUp]
6565
public void Init ()
6666
{
6767
Device.PlatformServices = new MockPlatformServices ();
6868
Ticker.Default = new BlockingTicker ();
6969
}
7070

71-
[TestFixtureTearDown]
71+
[OneTimeTearDown]
7272
public void End ()
7373
{
7474
Device.PlatformServices = null;
@@ -154,14 +154,14 @@ public void KineticFinished ()
154154
[TestFixture]
155155
public class TickerSystemEnabledTests
156156
{
157-
[TestFixtureSetUp]
157+
[OneTimeSetUp]
158158
public void Init ()
159159
{
160160
Device.PlatformServices = new MockPlatformServices ();
161161
Ticker.Default = new AsyncTicker();
162162
}
163163

164-
[TestFixtureTearDown]
164+
[OneTimeTearDown]
165165
public void End ()
166166
{
167167
Device.PlatformServices = null;

Xamarin.Forms.Core.UnitTests/NavigationUnitTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ public async Task CurrentPageChanged()
441441
}
442442

443443
[Test]
444-
public async void HandlesPopToRoot ()
444+
public async Task HandlesPopToRoot ()
445445
{
446446
var root = new ContentPage { Title = "Root" };
447447
var navPage = new NavigationPage (root);
@@ -489,7 +489,7 @@ public void DoesNotSendBackEventToNonCurrentPage ()
489489
}
490490

491491
[Test]
492-
public async void NavigatesBackWhenBackButtonPressed ()
492+
public async Task NavigatesBackWhenBackButtonPressed ()
493493
{
494494
var root = new ContentPage { Title = "Root" };
495495
var navPage = new NavigationPage (root);
@@ -503,7 +503,7 @@ public async void NavigatesBackWhenBackButtonPressed ()
503503
}
504504

505505
[Test]
506-
public async void DoesNotNavigatesBackWhenBackButtonPressedIfHandled ()
506+
public async Task DoesNotNavigatesBackWhenBackButtonPressedIfHandled ()
507507
{
508508
var root = new BackButtonPage { Title = "Root" };
509509
var second = new BackButtonPage () {Handle = true};
@@ -562,7 +562,7 @@ public void TestInsertPage()
562562
}
563563

564564
[Test]
565-
public async void TestRemovePage()
565+
public async Task TestRemovePage()
566566
{
567567
var root = new ContentPage { Title = "Root" };
568568
var newPage = new ContentPage();

Xamarin.Forms.Core.UnitTests/ResourceDictionaryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public void ShowKeyInExceptionIfNotFound()
261261
var rd = new ResourceDictionary();
262262
rd.Add("foo", "bar");
263263
var ex = Assert.Throws<KeyNotFoundException>(() => { var foo = rd ["test_invalid_key"]; });
264-
Assert.That(ex.Message, Is.StringContaining("test_invalid_key"));
264+
Assert.That(ex.Message, Does.Contain("test_invalid_key"));
265265
}
266266

267267
class MyRD : ResourceDictionary

Xamarin.Forms.Core.UnitTests/StyleTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public void TriggersAppliedAfterSetters ()
411411

412412
[Test]
413413
//https://bugzilla.xamarin.com/show_bug.cgi?id=31207
414-
public async void StyleDontHoldStrongReferences ()
414+
public async Task StyleDontHoldStrongReferences ()
415415
{
416416
var style = new Style (typeof(Label));
417417
var label = new Label ();

Xamarin.Forms.Core.UnitTests/TypedBindingUnitTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ public void OneTimeBindingDoesntUpdateNeedSettersOrHandlers()
14901490
}
14911491

14921492
[Test]
1493-
[Ignore]
1493+
[Ignore("SpeedTestApply")]
14941494
public void SpeedTestApply()
14951495
{
14961496

@@ -1560,7 +1560,7 @@ public void SpeedTestApply()
15601560
}
15611561

15621562
[Test]
1563-
[Ignore]
1563+
[Ignore("SpeedTestSetBC")]
15641564
public void SpeedTestSetBC()
15651565
{
15661566
var property = BindableProperty.Create("Foo", typeof(string), typeof(MockBindable));

Xamarin.Forms.Core.UnitTests/UriImageSourceTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static async Task<Stream> GetStreamAsync (Uri uri, CancellationToken cancellatio
4848
}
4949

5050
[Test]
51-
[Ignore]
51+
[Ignore("LoadImageFromStream")]
5252
public void LoadImageFromStream ()
5353
{
5454
var loader = new UriImageSource {
@@ -60,7 +60,7 @@ public void LoadImageFromStream ()
6060
}
6161

6262
[Test]
63-
[Ignore]
63+
[Ignore("SecondCallLoadFromCache")]
6464
public void SecondCallLoadFromCache ()
6565
{
6666
var loader = new UriImageSource {
@@ -80,7 +80,7 @@ public void SecondCallLoadFromCache ()
8080
}
8181

8282
[Test]
83-
[Ignore]
83+
[Ignore("DoNotKeepFailedRetrieveInCache")]
8484
public void DoNotKeepFailedRetrieveInCache ()
8585
{
8686
var loader = new UriImageSource {
@@ -98,7 +98,7 @@ public void DoNotKeepFailedRetrieveInCache ()
9898
}
9999

100100
[Test]
101-
[Ignore]
101+
[Ignore("ConcurrentCallsOnSameUriAreQueued")]
102102
public void ConcurrentCallsOnSameUriAreQueued ()
103103
{
104104
var loader = new UriImageSource {

0 commit comments

Comments
 (0)