Skip to content

Commit

Permalink
test: Replace existing NUnit assertions with updated ones to align wi…
Browse files Browse the repository at this point in the history
…th NUnit 4 standards. (#713)

* build(deps): Add NUnit.Analyzers 3.10.0 to test/integration

* build(deps): Bump NUnit from 3.14.0 to 4.0.1

* chore: Add rule NUnit1032 to recognize Quit as an additional dispose method

* Revert "build(deps): Bump NUnit from 3.14.0 to 4.0.1"

This reverts commit d391711.

* test: Replace existing NUnit assertions with updated ones to align with NUnit 4 standards.

* test: fix FindByAccessibilityIdTest null object reference

* test: fix flaky CheckAbilityToLogServiceOutputToConsole + CheckTheAbilityToDefineTheDesiredLogFile improvements
  • Loading branch information
Dor-bl authored Dec 23, 2023
1 parent 94ab0a9 commit 6d37359
Show file tree
Hide file tree
Showing 49 changed files with 353 additions and 265 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ indent_size = 4
[*.cs]
indent_style = space
indent_size = 4

# Set up additional disposal methods for a specific diagnostic rule
dotnet_diagnostic.NUnit1032.additional_dispose_methods = Quit
20 changes: 10 additions & 10 deletions test/integration/Android/ActivityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,53 +41,53 @@ public void StartActivityInThisAppTestCase()
{
_driver.StartActivity(AppId, ".ApiDemos");

Assert.AreEqual(_driver.CurrentActivity, ".ApiDemos");
Assert.That(_driver.CurrentActivity, Is.EqualTo(".ApiDemos"));

_driver.StartActivity(AppId, ".accessibility.AccessibilityNodeProviderActivity");

Assert.AreEqual(_driver.CurrentActivity, ".accessibility.AccessibilityNodeProviderActivity");
Assert.That(_driver.CurrentActivity, Is.EqualTo(".accessibility.AccessibilityNodeProviderActivity"));
}

[Test]
public void StartActivityWithWaitingAppTestCase()
{
_driver.StartActivity(AppId, ".ApiDemos", AppId, ".ApiDemos");

Assert.AreEqual(_driver.CurrentActivity, ".ApiDemos");
Assert.That(_driver.CurrentActivity, Is.EqualTo(".ApiDemos"));

_driver.StartActivity(AppId, ".accessibility.AccessibilityNodeProviderActivity",
"io.appium.android.apis", ".accessibility.AccessibilityNodeProviderActivity");

Assert.AreEqual(_driver.CurrentActivity, ".accessibility.AccessibilityNodeProviderActivity");
Assert.That(_driver.CurrentActivity, Is.EqualTo(".accessibility.AccessibilityNodeProviderActivity"));
}

[Test]
public void StartActivityInNewAppTestCase()
{
_driver.StartActivity(AppId, ".ApiDemos");

Assert.AreEqual(_driver.CurrentActivity, ".ApiDemos");
Assert.That(_driver.CurrentActivity, Is.EqualTo(".ApiDemos"));

_driver.StartActivity("com.android.contacts", ContactsActivity);

Assert.AreEqual(_driver.CurrentActivity, ContactsActivity);
Assert.That(_driver.CurrentActivity, Is.EqualTo(ContactsActivity));
_driver.PressKeyCode(AndroidKeyCode.Back);
Assert.AreEqual(_driver.CurrentActivity, ".ApiDemos");
Assert.That(_driver.CurrentActivity, Is.EqualTo(".ApiDemos"));
}

[Test]
public void StartActivityInNewAppTestCaseWithoutClosingApp()
{
_driver.StartActivity(AppId, ".accessibility.AccessibilityNodeProviderActivity");

Assert.AreEqual(_driver.CurrentActivity, ".accessibility.AccessibilityNodeProviderActivity");
Assert.That(_driver.CurrentActivity, Is.EqualTo(".accessibility.AccessibilityNodeProviderActivity"));

_driver.StartActivity("com.android.contacts", ContactsActivity, "com.android.contacts",
ContactsActivity, false);

Assert.AreEqual(_driver.CurrentActivity, ContactsActivity);
Assert.That(_driver.CurrentActivity, Is.EqualTo(ContactsActivity));
_driver.PressKeyCode(AndroidKeyCode.Back);
Assert.AreEqual(_driver.CurrentActivity, ".accessibility.AccessibilityNodeProviderActivity");
Assert.That(_driver.CurrentActivity, Is.EqualTo(".accessibility.AccessibilityNodeProviderActivity"));
}

[OneTimeTearDown]
Expand Down
46 changes: 23 additions & 23 deletions test/integration/Android/AndroidUiScrollableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,141 +20,141 @@ public void Setup()
public void NewScrollablesStartWithEmptyConstructorCall()
{
var statement = _sut.Build();
Assert.AreEqual(ScrollableCtor, statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor));
}

[Test]
public void NewScrollableUsesCustomScrollContainerSelector()
{
var selector = new AndroidUiSelector().Instance(7);
var statement = new AndroidUiScrollable(selector).Build();
Assert.AreEqual("new UiScrollable(new UiSelector().instance(7))", statement);
Assert.That(statement, Is.EqualTo("new UiScrollable(new UiSelector().instance(7))"));
}

[Test]
public void FlingBackwardAddsCorrectCallToStatement()
{
var statement = _sut.FlingBackward().Build();
Assert.AreEqual(ScrollableCtor + ".flingBackward()", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".flingBackward()"));
}

[Test]
public void FlingForwardAddsCorrectCallToStatement()
{
var statement = _sut.FlingForward().Build();
Assert.AreEqual(ScrollableCtor + ".flingForward()", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".flingForward()"));
}

[Test]
public void FlingToBeginningAddsCorrectCallToStatement()
{
var statement = _sut.FlingToBeginning(45).Build();
Assert.AreEqual(ScrollableCtor + ".flingToBeginning(45)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".flingToBeginning(45)"));
}

[Test]
public void FlingToEndAddsCorrectCallToStatement()
{
var statement = _sut.FlingToEnd(77).Build();
Assert.AreEqual(ScrollableCtor + ".flingToEnd(77)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".flingToEnd(77)"));
}

[Test]
public void GetChildByDescriptionAddsCorrectCallToStatement()
{
var statement = _sut.GetChildByDescription(new AndroidUiSelector(), "Hello World", false).Build();
Assert.AreEqual(ScrollableCtor + ".getChildByDescription(new UiSelector(), \"Hello World\", false)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".getChildByDescription(new UiSelector(), \"Hello World\", false)"));
}

[Test]
public void GetChildByInstanceAddsCorrectCallToStatement()
{
var statement = _sut.GetChildByInstance(new AndroidUiSelector(), 9).Build();
Assert.AreEqual(ScrollableCtor + ".getChildByInstance(new UiSelector(), 9)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".getChildByInstance(new UiSelector(), 9)"));
}

[Test]
public void GetChildByTextAddsCorrectCallToStatement()
{
var statement = _sut.GetChildByText(new AndroidUiSelector(), "Help", false).Build();
Assert.AreEqual(ScrollableCtor + ".getChildByText(new UiSelector(), \"Help\", false)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".getChildByText(new UiSelector(), \"Help\", false)"));
}

[Test]
public void ScrollBackwardAddsCorrectCallToStatement()
{
var statement = _sut.ScrollBackward(32).Build();
Assert.AreEqual(ScrollableCtor + ".scrollBackward(32)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".scrollBackward(32)"));
}

[Test]
public void ScrollDescriptionIntoViewAddsCorrectCallToStatement()
{
var statement = _sut.ScrollDescriptionIntoView("Description Here").Build();
Assert.AreEqual(ScrollableCtor + ".scrollDescriptionIntoView(\"Description Here\")", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".scrollDescriptionIntoView(\"Description Here\")"));
}

[Test]
public void ScrollForwardAddsCorrectCallToStatement()
{
var statement = _sut.ScrollForward(46).Build();
Assert.AreEqual(ScrollableCtor + ".scrollForward(46)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".scrollForward(46)"));
}

[Test]
public void ScrollIntoViewAddsCorrectCallToStatement()
{
var statement = _sut.ScrollIntoView(new AndroidUiSelector()).Build();
Assert.AreEqual(ScrollableCtor + ".scrollIntoView(new UiSelector())", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".scrollIntoView(new UiSelector())"));
}

[Test]
public void ScrollTextIntoViewAddsCorrectCallToStatement()
{
var statement = _sut.ScrollTextIntoView("Some Text").Build();
Assert.AreEqual(ScrollableCtor + ".scrollTextIntoView(\"Some Text\")", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".scrollTextIntoView(\"Some Text\")"));
}

[Test]
public void ScrollToBeginningAddsCorrectCallToStatement()
{
var statement = _sut.ScrollToBeginning(12, 90).Build();
Assert.AreEqual(ScrollableCtor + ".scrollToBeginning(12, 90)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".scrollToBeginning(12, 90)"));
}

[Test]
public void ScrollToEndAddsCorrectCallToStatement()
{
var statement = _sut.ScrollToEnd(32, 51).Build();
Assert.AreEqual(ScrollableCtor + ".scrollToEnd(32, 51)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".scrollToEnd(32, 51)"));
}

[Test]
public void SetScrollDirectionVerticalAddsCorrectCallToStatement()
{
var statement = _sut.SetScrollDirection(ListDirection.Vertical).Build();
Assert.AreEqual(ScrollableCtor + ".setAsVerticalList()", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".setAsVerticalList()"));
}

[Test]
public void SetScrollDirectionHorizontalAddsCorrectCallToStatement()
{
var statement = _sut.SetScrollDirection(ListDirection.Horizontal).Build();
Assert.AreEqual(ScrollableCtor + ".setAsHorizontalList()", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".setAsHorizontalList()"));
}

[Test]
public void SetMaxSearchSwipesAddsCorrectCallToStatement()
{
var statement = _sut.SetMaxSearchSwipes(80).Build();
Assert.AreEqual(ScrollableCtor + ".setMaxSearchSwipes(80)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".setMaxSearchSwipes(80)"));
}

[Test]
public void SetSwipeDeadZonePercentageAddsCorrectCallToStatement()
{
var statement = _sut.SetSwipeDeadZonePercentage(.67).Build();
Assert.AreEqual(ScrollableCtor + ".setSwipeDeadZonePercentage(0.67)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".setSwipeDeadZonePercentage(0.67)"));
}

[TestCase(1.1)]
Expand All @@ -172,22 +172,22 @@ public void SomeStatementsCanBeChained()
.SetSwipeDeadZonePercentage(0.11)
.SetMaxSearchSwipes(44)
.Build();
Assert.AreEqual(ScrollableCtor + ".setSwipeDeadZonePercentage(0.11).setMaxSearchSwipes(44)", statement);
Assert.That(statement, Is.EqualTo(ScrollableCtor + ".setSwipeDeadZonePercentage(0.11).setMaxSearchSwipes(44)"));
}

[Test]
public void AddRawTextAppendsText()
{
var statment = _sut.AddRawText("@").Build();
Assert.AreEqual(ScrollableCtor + "@", statment);
Assert.That(statment, Is.EqualTo(ScrollableCtor + "@"));
}

[Test]
public void RequestingStatementTerminationOnBuildAppendsSemicolon()
{
var statement = _sut.SetSwipeDeadZonePercentage(.67).Build(true);
var lastCharOfStatement = statement[statement.Length - 1];
Assert.AreEqual(';', lastCharOfStatement);
Assert.That(lastCharOfStatement, Is.EqualTo(';'));
}
}
}
Loading

0 comments on commit 6d37359

Please sign in to comment.