[英]How to run ruby test with watir on jenkins slave?
我已經在名為machineA的Windows 7機器上安裝了jenkins主節點和testLink。 我已經在Windows Server 2003上通過Java Web Start(JNLP)安裝了Ruby 1.8.7,watir 1.7.1,ci_reporter 1.8.4,測試單元2.5.4,rake 10.0.3,jenkins從屬節點,該服務器稱為Windows Server 2003。
該項目的目的是從machineA開始構建,之后,jenkins從屬服務器將在machineB上執行ruby測試(使用watir,即使用navigator),並在machineA上發送報告(由testLink讀取)。
我在jenkins主節點上的工作配置(在machineA上):
restrict where this project can be run --> machineB
svn --> url --> svn://serverSVN/project/trunk
build --> invoke testlink --> testLink cfg --> TestLink Version --> testlink 1.9.3
Test Project Name --> my project
Test Plan Name --> my testPlan
Build Name --> watirTest-$BUILD_NUMBER
Custom Fields --> watir
testExecution --> Single Build Steps --> execute windows batch cmd --> rake test CI_REPORTS=results
results seeking strategy --> include pattern --> results/*.xml
key custom field --> watir
post-action-build --> publish junit reports --> results/*.xml
在這里,我將以兩種不同的方式執行測試(在machineB上本地執行,並使用來自machineA的Jenkins執行)。
require 'rubygems'
require 'watir'
require 'test/unit'
require 'ci/reporter/rake/test_unit_loader'
include Watir
class ModifierLocalisation < Test::Unit::TestCase
def test_me
ie = Watir::IE.new
ie.goto("http://ipMachine/shopA/")
assert(ie.text.include?("Identification"))
end
end
當我在本地計算機B上執行測試時,測試通過了,因此控制台輸出如下:
** Invoke test (first_time)
** Execute test
E:/Ruby/bin/ruby.exe test/modifierLocalisation.rb
Loaded suite test/modifierLocalisation
Started
.
Finished in 2.140625 seconds.
1 tests, 1 assertions, 1 failures, 0 errors
但是,當我在machineA上使用jenkins執行測試時,測試失敗,(但報告已發送至machineA上的testLink),因此控制台輸出如下:
** Invoke test (first_time)
** Execute test
E:/Ruby/bin/ruby.exe test/modifierLocalisation.rb
Loaded suite test/modifierLocalisation
Started
F
Finished in 2.140625 seconds.
1) Failure:
test_me(ModifierLocalisation) [test/modifierLocalisation.rb:14]:
<false> is not true.
1 tests, 1 assertions, 1 failures, 0 errors
rake aborted!
我認為當我在機器A上從詹金斯執行測試時,Internet Explorer無法啟動,這就是測試失敗的原因。
關於我能做什么的任何想法?
您可以從機器A遠程運行硒測試。
在您的代碼更改中
ie = Watir::IE.new
至
capabilities = WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
ie = Watir::Browser.new(:remote, :url => 'http://machineB:4444/wd/hub', :desired_capabilities => capabilities)
ie = Watir::Browser.new :ie
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.