swift - 用于分离 UITest 代码的 Swift 条件语句
问题描述
IF UItest is running
{
//execute this code
}
else
{
//execute this code
}
谁能告诉这里的条件语句应该是什么
解决方案
方法一:通过测试代码传递args
// In UI test file
class ProfileUI: XCTestCase {
let app = XCUIApplication()
override func setUpWithError() throws {
app.launchArguments = ["-isUITestMode", "user_324234"]
app.launch()
}
}
方法2:通过scheme传递args
检查参数
if CommandLine.arguments.contains("-isUITestMode") {
// running ui test
} else if CommandLine.arguments.contains("-isUnitTestMode") {
// running unit tests
} else {
// normal
}
推荐阅读
- css - css如何将一个标题单元格合并到一个单元格中
- c++ - C++文件io多行
- sql - 仅通过 SQL 显示在 DBGrid 中的 TCheckListBox 中选择的字段
- vaadin - 在 Tomcat 容器上运行时,聚合物资源 URL 在“上下文”下不起作用
- javascript - 使用javascript/jquery根据另一个选择的值显示/隐藏选择选项?
- html - 禁用时阻止锚点像超链接一样
- java - 如何以正确的顺序销毁 bean(使用会话和单例范围)?
- vue.js - 检查对象是否存在而不抛出错误
- sql - Redshift 数值精度截断
- sybase - 阻止智能感知更改我的表格别名