visual-studio-app-center - 如何仅在特定于 Android 和 iOS 的 AppCenter 上运行自动化测试?
问题描述
我正在使用 Xamarin.UITest 和 NUnit 来自动化移动应用程序,并正在使用 Azure DevOps 管道在 AppCenter 上运行测试。这些测试目前在 AppCenter 上的 Android 和 iOS 平台上运行良好。但是,我有一个要求,我想只在 Android 上运行特定的测试,而只在 iOS 上运行。任何人都可以分享一些关于如何实现这一点的建议吗?
解决方案
最后,我自己找到了解决方案。我通过在 Setup 方法中的每次测试之前检查平台来使其工作。请找到我用 C# 和 NUnit 编写的以下代码。例如,有 2 个测试,其中只有一个测试应该运行,另一个不应该运行,然后有一个测试(需要运行)的类别标记为 iOS,而另一个没有类别。
[TextFixture(Platform.Android)]
[TextFixture(Platform.iOS)]
public class Sample{
[SetUp]
public void RunBeforeEachTest()
{
if(AppManager.Platform == Platform.iOS)
{
if(!hasiOSCategory())
{
Assert.Inconclusive();
}
}
}
然后在 setup 方法中进行检查,验证当前平台是否为 iOS 并检查测试是否有 iOS 类别
// this method is used to get all categories of the test.
private static bool hasiOSCategory()
{
var categories = TestContext.CurrentContext.Test?.Properties["Category"];
bool hasTestContainsiOSCategory = categories != null && categories.Contains(Constant.iOS);
return hasTestContainsiOSCategory;
}
[Test,Category("iOS")]
public void TestWithCategory()
{
\\your code
}
[Test]
public void TestWithoutCategory()
{
}
}
最后,如果可以在框架中实现一件事,那么它也应该在 AppCenter 上工作。
推荐阅读
- python-3.x - 谁能帮我在 Windows 上安装 PYPY?
- python - 具有一维输入向量和二维输出向量的 SVR 模型
- autodesk-forge - 在 Autodesk Forge Viewer 中首次加载文件时,仅加载特定的 GUID 作为优先级
- hashmap - ADA - 哈希图中的记录。打印哈希图的问题
- c# - 使用来自另一个 ViewModel 的 treeview 的 selectedItem
- node.js - 在 npm start 时显示错误,但随后运行顺利... [MongoError: Topology closed]
- gensim - MemoryError: Unable to allocate 380. MiB for an array with shape (331792, 300) and data type float32
- java - 使用 TreeSet Java 计算反转
- excel - 使用自动填充增量
- azure - Azure Blob 存储:使用 C# 从 Azure 存储容器“$logs”下载所有日志