This commit is contained in:
Scott McKay 2024-12-05 18:17:05 +10:00
Родитель c9b2ca30a8
Коммит c8a857fb2c
5 изменённых файлов: 46 добавлений и 28 удалений

Просмотреть файл

@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Microsoft.ML.OnnxRuntime.Tests.MAUI"
x:Class="Microsoft.ML.OnnxRuntime.Tests.MAUI.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

Просмотреть файл

@ -0,0 +1,12 @@
namespace Microsoft.ML.OnnxRuntime.Tests.MAUI
{
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new AppShell();
}
}
}

Просмотреть файл

@ -18,27 +18,23 @@ internal partial class AppiumHelper : IDisposable
public AppiumDriver App => driver ?? throw new NullReferenceException("AppiumDriver is null");
public void Start()
public AppiumHelper()
{
if (driver is not null)
{
throw new InvalidOperationException("AppiumDriver is already started.");
}
server = new AppiumLocalServer(DefaultHostAddress, DefaultHostPort);
driver = CreateDriver(); // this function is implemented in the platform specific code
}
public void Stop()
{
// this seems to kill the app if everything works correctly but isn't as consistent if it fails due to a
// zombie process. trying using autoterminate in MauiProgram.cs for a more graceful way, but not sure if
// BrowserStack will require Quit to be explicitly called. this needs more debugging
driver?.Quit();
driver = null;
server?.Dispose();
server = null;
// this seems to kills the app if everything works correctly but isn't as consistent if it fails due to a
// zombie process. trying using autoterminate in MauiProgram.cs for a more graceful way, but not sure if
// BrowserStack will require Quit to be explicitly called.
// driver?.Quit();
// driver = null;
}
protected virtual void Dispose(bool disposing)

Просмотреть файл

@ -45,11 +45,7 @@ public class XunitTestRunnerWithAppium : ITestRunner
{
using (var appiumHelper = new AppiumHelper())
{
appiumHelper.Start();
await runTests();
// this seems to close the app. not sure if there's a higher up place we could/should do that or not.
// the IResultChannel is still open, so we could potentially do it there.
appiumHelper.Stop();
}
}
catch (Exception ex)

Просмотреть файл

@ -85,15 +85,9 @@
</ItemGroup>
<ItemGroup>
<ProjectReference
Include="..\..\src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj"
name="Microsoft.ML.OnnxRuntime" />
<ProjectReference
Include="..\Microsoft.ML.OnnxRuntime.Tests.Common\Microsoft.ML.OnnxRuntime.Tests.Common.csproj"
name="Microsoft.ML.OnnxRuntime.Tests.Common" />
<ProjectReference
Include="..\Microsoft.ML.OnnxRuntime.Tests.Devices\Microsoft.ML.OnnxRuntime.Tests.Devices.csproj"
name="Microsoft.ML.OnnxRuntime.Tests.Devices" />
<ProjectReference Include="..\..\src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj" name="Microsoft.ML.OnnxRuntime" />
<ProjectReference Include="..\Microsoft.ML.OnnxRuntime.Tests.Common\Microsoft.ML.OnnxRuntime.Tests.Common.csproj" name="Microsoft.ML.OnnxRuntime.Tests.Common" />
<ProjectReference Include="..\Microsoft.ML.OnnxRuntime.Tests.Devices\Microsoft.ML.OnnxRuntime.Tests.Devices.csproj" name="Microsoft.ML.OnnxRuntime.Tests.Devices" />
</ItemGroup>
<ItemGroup>
@ -108,6 +102,14 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.utility" Version="2.9.0" />
<!-- tried adding this to see if `dotnet test` can discover tests, but it just broke the setup and build.
Did not try adding xunit.runner.visualstudio without dotnet-xunit though
<PackageReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
-->
</ItemGroup>
<ItemGroup Condition="$(IsIOSTarget)=='true' OR $(IsMacCatalystTarget)=='true'">
@ -117,9 +119,7 @@
<Target Name="RemoveVisualStudioTestRunner" BeforeTargets="_ComputeAppxPackagePayload">
<ItemGroup>
<_VisualStudioTestRunnerFiles
Include="@(PackagingOutputs)"
Condition="$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" />
<_VisualStudioTestRunnerFiles Include="@(PackagingOutputs)" Condition="$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" />
<PackagingOutputs Remove="@(_VisualStudioTestRunnerFiles)" />
</ItemGroup>
</Target>