Appium:Ruby:iOS 的 appium 分布式测试
Appium: Ruby: Distributed tests with appium for iOS
我有一个完全成熟的自动化测试套件,使用 ruby 和用于移动自动化的 Appium 编写。
我运行将这些套件集成在一个模拟器中 machine 并且它占用了很多时间,大约 1 小时 运行 56 个测试用例(我们有集成了 database/Api/functional 等多项检查的系统测试用例)。我们有更多额外的测试用例添加到我们的方式中。
我们已经 运行 在 3 个 mac mac 引擎中实施了我们的测试,目前 运行 将不同的黄瓜标签集成到 Jenkins 中。然而,更多的测试只会花费我们更多的时间或更多 mac's
使用xcode 9我们可以同时在一个machine上启动多个模拟器,我想知道是否有关于如何实现分布式的示例场景或文档在一个 mac machine
中进行跨模拟器测试
我曾尝试使用不同的平台版本加载两三个不同的所需功能,但它只能按顺序加载测试。
我在网上浏览了很多 material,其中只有在 android 中实现这一目标的步骤。 iOS支持吗?
或者谁能提供对我有帮助的链接?到
1. 在一个平台上实现跨各种模拟器的分布式测试 mac
2. 使用黄瓜标签分发测试,为每个所需的功能创建实例
更新:
我曾尝试实施多线程选项,并尝试启动对特定模拟器创建每个线程实例的测试。但是,我发现测试不是 运行 并行而是顺序进行。
这是我的代码:
def start_app(device_id, wdalocalport)
caps_config = {
platformName: "iOS",
wdaLocalPort: wdalocalport,
deviceName: "iPhone Simulator", #update device as per your need
app: (File.join(File.dirname(__FILE__), "Sequoia.app")),
bundleId: "something",
automationName: "XCUITest",
xcodeOrgId: "something",
xcodeSigningId: "iPhone Developer",
#platformVersion: "10.2",
noReset: "true",
fullReset: "false",
showIOSLog: "true",
autoAcceptAlerts: "true",
showXcodeLog: "true",
useNewWDA: "true",
resetOnSessionStartOnly: "true",
udid: device_id }
appium_lib_config={ port: 4723 }
$opts={ caps: caps_config, appium_lib: appium_lib_config }
setup
end
def setup
@appium = Appium::Driver.new($opts)
@appium.start_driver
#Makes all appium_lib methods accessible from steps
#Starts appium driver before the tests begin
end
def test(device1,device2)
threads = []
threads << Thread.new {
start_app(device1, '8100')
}
threads << Thread.new {
start_app(device2, '8200')
}
threads.each(&:join)
end
end
我正在使用传递 udid's
的 test
方法调用启动测试。模拟器同时启动,同时安装应用程序,但测试不是并行的。
对即兴创作这个案例有什么帮助吗?
我能够使用 rake
并行 运行,但我仍然发现这种方法 运行 以顺序方式进行测试或根本不 运行
PFB代码
def run_cucumber(cucumber_options)
Cucumber::Rake::Task.new do |t|
t.cucumber_opts = cucumber_options
end
Rake::Task[:cucumber].invoke
end
task :iphone_7 do |t|
ENV['DEVICE'] = 'iphone7'
run_cucumber('-r features features/test.feature --format pretty --tags @slave1')
end
task :iphone_8 do |t|
ENV['DEVICE'] = 'iphone8'
run_cucumber('-r features features/test.feature --format pretty --tags @slave2')
end
multitask :all => [:iphone_7,:iphone_8]
我的hooks.rb
Before do
check
end
def check
if ENV['DEVICE'] == 'iphone7'
start_app('iPhone6','port','udid')
elsif ENV['DEVICE'] == 'iphone8'
start_app('iphone6','port','udid')
else
puts "Device not"
end
end
我得到了 DEVICE NOT
。不确定我错过了什么。
您需要先在 Rakefile 中创建一个调用 cucumber rake 的方法,如下所示:
def run_cucumber(cucumber_options)
Cucumber::Rake::Task.new do |t|
t.cucumber_opts = cucumber_options
end
Rake::Task[:cucumber].invoke
end
此方法需要 cucumber_options。您可以像这样在命令行上传递相同的选项:
-r features features/test.feature --format pretty --tags @test1
在此之后,在同一 Rakefile 中为特定配置定义 rake 任务:
task :iphone_7 do |t|
ENV["DEVICE"] = "iphone 7"
run_cucumber('-r features features/test.feature --format pretty --tags @test1')
end
task :iphone_8 do |t|
ENV["DEVICE"] = "iphone 8"
run_cucumber('-r features features/test.feature --format pretty --tags @test2')
end
此处,ENV["DEVICE"] 用于设置设备配置。您可以在 Before 块中的 env.rb 中使用此变量来初始化测试。在 Before 块中,您可以根据此环境变量初始化设备。
您可以根据需要创建任意数量的此类 rake 任务。
然后您可以使用ruby的并行gem同时调用多个任务。示例在此 link -> Ruby Parallel gem
只需将不同类型的 rake 任务作为参数传递给 Parallel 对象。
例如:
task :run_parallel do |t|
Parallel.map([:iphone_7,:iphone_8]) {|task| Rake::Task[task].invoke }
end
然后触发run_parallelrake任务执行全部代码。
例如:
bundle exec rake run_parallel
我有一个完全成熟的自动化测试套件,使用 ruby 和用于移动自动化的 Appium 编写。
我运行将这些套件集成在一个模拟器中 machine 并且它占用了很多时间,大约 1 小时 运行 56 个测试用例(我们有集成了 database/Api/functional 等多项检查的系统测试用例)。我们有更多额外的测试用例添加到我们的方式中。
我们已经 运行 在 3 个 mac mac 引擎中实施了我们的测试,目前 运行 将不同的黄瓜标签集成到 Jenkins 中。然而,更多的测试只会花费我们更多的时间或更多 mac's
使用xcode 9我们可以同时在一个machine上启动多个模拟器,我想知道是否有关于如何实现分布式的示例场景或文档在一个 mac machine
中进行跨模拟器测试我曾尝试使用不同的平台版本加载两三个不同的所需功能,但它只能按顺序加载测试。
我在网上浏览了很多 material,其中只有在 android 中实现这一目标的步骤。 iOS支持吗?
或者谁能提供对我有帮助的链接?到 1. 在一个平台上实现跨各种模拟器的分布式测试 mac 2. 使用黄瓜标签分发测试,为每个所需的功能创建实例
更新:
我曾尝试实施多线程选项,并尝试启动对特定模拟器创建每个线程实例的测试。但是,我发现测试不是 运行 并行而是顺序进行。
这是我的代码:
def start_app(device_id, wdalocalport)
caps_config = {
platformName: "iOS",
wdaLocalPort: wdalocalport,
deviceName: "iPhone Simulator", #update device as per your need
app: (File.join(File.dirname(__FILE__), "Sequoia.app")),
bundleId: "something",
automationName: "XCUITest",
xcodeOrgId: "something",
xcodeSigningId: "iPhone Developer",
#platformVersion: "10.2",
noReset: "true",
fullReset: "false",
showIOSLog: "true",
autoAcceptAlerts: "true",
showXcodeLog: "true",
useNewWDA: "true",
resetOnSessionStartOnly: "true",
udid: device_id }
appium_lib_config={ port: 4723 }
$opts={ caps: caps_config, appium_lib: appium_lib_config }
setup
end
def setup
@appium = Appium::Driver.new($opts)
@appium.start_driver
#Makes all appium_lib methods accessible from steps
#Starts appium driver before the tests begin
end
def test(device1,device2)
threads = []
threads << Thread.new {
start_app(device1, '8100')
}
threads << Thread.new {
start_app(device2, '8200')
}
threads.each(&:join)
end
end
我正在使用传递 udid's
的 test
方法调用启动测试。模拟器同时启动,同时安装应用程序,但测试不是并行的。
对即兴创作这个案例有什么帮助吗?
我能够使用 rake
并行 运行,但我仍然发现这种方法 运行 以顺序方式进行测试或根本不 运行
PFB代码
def run_cucumber(cucumber_options)
Cucumber::Rake::Task.new do |t|
t.cucumber_opts = cucumber_options
end
Rake::Task[:cucumber].invoke
end
task :iphone_7 do |t|
ENV['DEVICE'] = 'iphone7'
run_cucumber('-r features features/test.feature --format pretty --tags @slave1')
end
task :iphone_8 do |t|
ENV['DEVICE'] = 'iphone8'
run_cucumber('-r features features/test.feature --format pretty --tags @slave2')
end
multitask :all => [:iphone_7,:iphone_8]
我的hooks.rb
Before do
check
end
def check
if ENV['DEVICE'] == 'iphone7'
start_app('iPhone6','port','udid')
elsif ENV['DEVICE'] == 'iphone8'
start_app('iphone6','port','udid')
else
puts "Device not"
end
end
我得到了 DEVICE NOT
。不确定我错过了什么。
您需要先在 Rakefile 中创建一个调用 cucumber rake 的方法,如下所示:
def run_cucumber(cucumber_options)
Cucumber::Rake::Task.new do |t|
t.cucumber_opts = cucumber_options
end
Rake::Task[:cucumber].invoke
end
此方法需要 cucumber_options。您可以像这样在命令行上传递相同的选项:
-r features features/test.feature --format pretty --tags @test1
在此之后,在同一 Rakefile 中为特定配置定义 rake 任务:
task :iphone_7 do |t|
ENV["DEVICE"] = "iphone 7"
run_cucumber('-r features features/test.feature --format pretty --tags @test1')
end
task :iphone_8 do |t|
ENV["DEVICE"] = "iphone 8"
run_cucumber('-r features features/test.feature --format pretty --tags @test2')
end
此处,ENV["DEVICE"] 用于设置设备配置。您可以在 Before 块中的 env.rb 中使用此变量来初始化测试。在 Before 块中,您可以根据此环境变量初始化设备。
您可以根据需要创建任意数量的此类 rake 任务。
然后您可以使用ruby的并行gem同时调用多个任务。示例在此 link -> Ruby Parallel gem 只需将不同类型的 rake 任务作为参数传递给 Parallel 对象。 例如:
task :run_parallel do |t|
Parallel.map([:iphone_7,:iphone_8]) {|task| Rake::Task[task].invoke }
end
然后触发run_parallelrake任务执行全部代码。 例如:
bundle exec rake run_parallel