xamarin - 从命令行为特定平台运行 Xamarin.UI 测试

标签 xamarin .net-core nunit nunit-console xamarin.uitest

我有一个 Xamarin.UITest项目比包含 Android 和 iOS 的 UI 测试。所有测试都继承自一个如下所示的基类:

[TestFixture(Platform.Android)]
[TestFixture(Platform.iOS)]
public abstract class UITestBase
{
    private readonly Platform _platform;
    protected IApp App { get; private set; }

    protected UITestBase(Platform platform)
    {
        _platform = platform;
    }

    [SetUp]
    protected virtual async Task BeforeEachTest()
    {
        App = AppInitializer.StartApp(_platform);
        await Task.CompletedTask;
    }
}

因此,所有测试都将针对 Android 和 iOS 运行。现在,在诸如 Visual Studio 或 Rider 之类的 IDE 中,它可以轻松地让我仅针对特定平台运行测试 - 例如,在开发时,我通常只想运行针对 Android 的测试。

如何从命令行仅针对特定平台运行测试?
dotnet test将在两个平台上运行它们,我看不到使用 NUnit 的 TestFixture 进行过滤的方法属性。

虽然我更喜欢使用 dotnet test 的方法,也可以使用 NUnit 控制台运行程序,nunit3-console.exe ,但我还是不知道如何使用 TestFixture 进行过滤论据。

最佳答案

使用 dotnet-test(见 run selective unit tests)

dotnet test Tests.dll--filter iOS

dotnet test Tests.dll--filter Android
或者使用 nunit3-console-runner 和 Test Selection Language :
nunit3-console.exe Tests.dll --where "test =~ iOS"

nunit3-console.exe Tests.dll --where "test =~ Android"

关于xamarin - 从命令行为特定平台运行 Xamarin.UI 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58624867/

相关文章:

c# - VS 2008——在构建属性中使用相对路径

visual-studio - 如何配置 Resharper 使其 "allows"在方法名称中有下划线?

xamarin.ios - 添加用户定义的运行时属性?

xamarin - 如何在 Android 和 iOS (Xamarin Forms) 上获取键盘高度?

ios - 使用 Xamarin iOS 进行客户端证书身份验证

c# - OAEP RSA 参数与 RSACryptoServiceProvider.Encrypt

asp.net - 在 Azure 应用服务 (AAS) 窗口中运行的 .NET Core 应用程序的日志流中未显示应用程序日志

javascript - Xamarin : use Android WebView EvaluateJavascript

c# - .NET Core - 使用 Request-Id 将传入请求挂接到出站 HTTP 请求

c# - 从 Nunit3-console.exe 运行单独测试