Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavAntonyuk committed Mar 1, 2024
1 parent ea472e8 commit b8ad6dd
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 48 deletions.
4 changes: 2 additions & 2 deletions MauiTests/Client.Android.UITests/AppiumSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static AndroidSdkManager InstallSoftware()
{
sdk.AvdManager.Create(AvdName, avdSdkId, "pixel", force: true);
}

return sdk;
}

Expand All @@ -74,7 +74,7 @@ private string GetApp()
#endif
const string testsPath = $@"Client.Android.UITests\bin\{configuration}\net8.0";
var solutionPath = Environment.CurrentDirectory.Replace(testsPath, string.Empty);
var path = $@"{solutionPath}MauiTests\Client\bin\{configuration}\net8.0-android\{PackageName}-Signed.apk";
var path = $@"{solutionPath}Client\bin\{configuration}\net8.0-android\{PackageName}-Signed.apk";
testOutputHelper.WriteLine(path);
return path;
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion MauiTests/Client.MacCatalyst.UITests/AppiumSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private string GetApp()
#endif
const string testsPath = $@"Client.MacCatalyst.UITests\bin\{configuration}\net8.0";
var solutionPath = Environment.CurrentDirectory.Replace(testsPath, string.Empty);
var path = $@"{solutionPath}MauiTests\Client\bin\{configuration}\net8.0-maccatalyst\maccatalyst-x64\Client.app";
var path = $@"{solutionPath}Client\bin\{configuration}\net8.0-maccatalyst\maccatalyst-x64\Client.app";
testOutputHelper.WriteLine(path);
return path;
}
Expand Down
5 changes: 3 additions & 2 deletions MauiTests/Client.Shared.UITests/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ public Task DisposeAsync()
return Task.CompletedTask;
}

protected void VerifyScreenshot(string name)
protected async Task VerifyScreenshot(string name)
{
if (App.PlatformName == "Windows")
{
var handle = App.CurrentWindowHandle;
MoveWindow(IntPtr.Parse(handle[2..], NumberStyles.HexNumber), 0, 0, 800, 600, true);
await Task.Delay(1000);
}

var screenshotPngBytes = App.GetScreenshot().AsByteArray;

var actualImage = new ImageSnapshot(screenshotPngBytes, ImageSnapshotFormat.PNG);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Client.UITests;

public class LoginPageTests(ITestOutputHelper testOutputHelper) : BaseTest(testOutputHelper)
public class MainPageTests(ITestOutputHelper testOutputHelper) : BaseTest(testOutputHelper)
{
[AllowOnPlatformFact(
RuntimePlatform.WindowsAndroid,
Expand All @@ -13,7 +13,7 @@ public class LoginPageTests(ITestOutputHelper testOutputHelper) : BaseTest(testO
public async Task AppLaunches()
{
await Task.Delay(2000);
VerifyScreenshot($"{nameof(AppLaunches)}");
await VerifyScreenshot($"{nameof(AppLaunches)}");
}

[AllowOnPlatformFact(
Expand All @@ -24,7 +24,7 @@ public async Task AppLaunches()
RuntimePlatform.WindowsWindows,
RuntimePlatform.OsxTizen
)]
public async Task LoginBtnTest()
public async Task CounterBtnTest()
{
// Arrange
var element = FindUiElement("CounterBtn");
Expand Down
2 changes: 1 addition & 1 deletion MauiTests/Client.Tizen.UITests/AppiumSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private string GetApp()
#endif
const string testsPath = $@"Client.Tizen.UITests\bin\{configuration}\net8.0";
var solutionPath = Environment.CurrentDirectory.Replace(testsPath, string.Empty);
var path = $@"{solutionPath}MauiTests\Client\bin\{configuration}\\net8.0-tizen\tizen-x86\com.vladislavantonyuk.client-1.0.0.tpk";
var path = $@"{solutionPath}Client\bin\{configuration}\\net8.0-tizen\tizen-x86\com.vladislavantonyuk.client-1.0.0.tpk";
testOutputHelper.WriteLine(path);
return path;
}
Expand Down
2 changes: 1 addition & 1 deletion MauiTests/Client.Windows.UITests/AppiumSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private string GetApp()
#endif
const string testsPath = $@"Client.Windows.UITests\bin\{configuration}\net8.0";
var solutionPath = Environment.CurrentDirectory.Replace(testsPath, string.Empty);
var path = $@"{solutionPath}MauiTests\Client\bin\{configuration}\\net8.0-windows10.0.19041.0\\win10-x64\\Client.exe";
var path = $@"{solutionPath}Client\bin\{configuration}\net8.0-windows10.0.19041.0\win10-x64\Client.exe";
testOutputHelper.WriteLine(path);
return path;
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion MauiTests/Client.iOS.UITests/AppiumSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private string GetApp()
#endif
const string testsPath = $@"Client.iOS.UITests\bin\{configuration}\net8.0";
var solutionPath = Environment.CurrentDirectory.Replace(testsPath, string.Empty);
var path = $@"{solutionPath}MauiTests\Client\bin\{configuration}\net8.0-ios\iossimulator-x64\Client.app";
var path = $@"{solutionPath}Client\bin\{configuration}\net8.0-ios\iossimulator-x64\Client.app";
testOutputHelper.WriteLine(path);
return path;
}
Expand Down
3 changes: 2 additions & 1 deletion MauiTests/Client/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

<Button
x:Name="CounterBtn"
Text="Click me"
AutomationId="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Fill" />
Expand Down
77 changes: 41 additions & 36 deletions MauiTests/Client/Platforms/Windows/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,46 @@
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" />

<mp:PhoneIdentity PhoneProductId="3BB43496-28AC-49CE-BD07-80F6E2AE2C7D" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>$placeholder$</DisplayName>
<PublisherDisplayName>User Name</PublisherDisplayName>
<Logo>$placeholder$.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate" />
</Resources>

<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="$placeholder$"
Description="$placeholder$"
Square150x150Logo="$placeholder$.png"
Square44x44Logo="$placeholder$.png"
BackgroundColor="transparent">
<uap:DefaultTile Square71x71Logo="$placeholder$.png" Wide310x150Logo="$placeholder$.png" Square310x310Logo="$placeholder$.png" />
<uap:SplashScreen Image="$placeholder$.png" />
</uap:VisualElements>
</Application>
</Applications>

<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
<Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" />

<mp:PhoneIdentity PhoneProductId="3BB43496-28AC-49CE-BD07-80F6E2AE2C7D" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>$placeholder$</DisplayName>
<PublisherDisplayName>User Name</PublisherDisplayName>
<Logo>$placeholder$.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate" />
</Resources>

<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="$placeholder$"
Description="$placeholder$"
Square150x150Logo="$placeholder$.png"
Square44x44Logo="$placeholder$.png"
BackgroundColor="transparent">
<uap:DefaultTile Square71x71Logo="$placeholder$.png" Wide310x150Logo="$placeholder$.png" Square310x310Logo="$placeholder$.png" />
<uap:SplashScreen Image="$placeholder$.png" />
</uap:VisualElements>
<Extensions>
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="client"/>
</uap:Extension>
</Extensions>
</Application>
</Applications>

<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>

</Package>
7 changes: 7 additions & 0 deletions MauiTests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# MauiTests

[![Buy Me A Coffee](https://ik.imagekit.io/VladislavAntonyuk/vladislavantonyuk/misc/bmc-button.png)](https://www.buymeacoffee.com/vlad.antonyuk)

Article: https://vladislavantonyuk.github.io/articles/Testing-.NET-MAUI-Application-using-Appium-and-xUnit

[![Stand With Ukraine](https://img.shields.io/badge/made_in-ukraine-ffd700.svg?labelColor=0057b7)](https://stand-with-ukraine.pp.ua)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ The development guide can be found at [SETUP.md](./SETUP.md).

1. [MauiTaskListApp](Database/MauiTaskListApp) - Cross-platform .NET MAUI app using MVVM development architecture performing CRUD operations with EF Core InMemory.

1. [MauiTests](MauiTests) - Testing .NET MAUI application using Appium and xUnit.

[![Stand With Ukraine](https://img.shields.io/badge/made_in-ukraine-ffd700.svg?labelColor=0057b7)](https://stand-with-ukraine.pp.ua)

0 comments on commit b8ad6dd

Please sign in to comment.