[DMY] [VB] [VB6] [Python] [C#] [Android] [電子工作] [個人メモ] [仕事メモ] [アイデア] [TstLink] [CE] [LTSA]
[自動化] [Qt] [OCaml] [3Dプリンタ] [TOOLS] [RAA] [Forge]
[機能別索引] [逆引きRuby] [マニュアル] [るびま] [標準ライブラリ] [るりまサーチ] [Try! Ruby] [PRaggerまとめ] [ピジョン・ブラッド]
[Rubyコーディング規約] [プログラミングのオキテ] [Rubyist SNS] [TOOLBIS]
[RubyネットワークProg] [druby] [コードなにがし] [RDocテンプレ] [Ruby/Tkサンプル]
[WAVE] [Xperia] [github] [twitterなど] [EA] [マクロ]
2008-05-01
TestLink 1.8betaのXMLRPCを動かしてみる
|TestLink1.8betaをDL、インストール
以下からDLします
http://sourceforge.net/project/showfiles.php?group_id=90976&package_id=270236&release_id=589128
XMLAPIを使うためconfig.inc.phpを変更
/** SOAP API availability (disabled by default) */
$tlCfg->api_enabled = FALSE;
を
/** SOAP API availability (disabled by default) */
$tlCfg->api_enabled = TRUE;
に変更
※以下は最新の1.8では対策済みで不要なので消しました。
APIErrors.phpとlang_api.phpを変更
そのまま実行すると以下のエラーがでるので
C:/ruby-1.8/lib/ruby/1.8/xmlrpc/client.rb:552:in `do_rpc': Wrong content-type: (RuntimeError)
Fatal error: Call to undefined function lang_get() in C:\xampplite\htdocs\testlink_beta\lib\api\APIErrors.php on line 29
from C:/ruby-1.8/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2'
from C:/ruby-1.8/lib/ruby/1.8/xmlrpc/client.rb:410:in `call'
from C:/xampplite/htdocs/testlink_beta/lib/api/sample_clients/ruby/clientSample.rb:18:in `reportTCResult'
from C:/xampplite/htdocs/testlink_beta/lib/api/sample_clients/ruby/clientSample.rb:26
Complete(1
以下の修正をします(市川さんからの情報です。ありがとうございます)
APIErrors.phpに↓を追加
require_once("../functions/lang_api.php");
lang_api.phpに↓を追加
例
testlink_beta\lib\api\APIErrors.php
/**
* general config file gives us lang_get access
*/
testlink_beta\lib\functions\lang_api.php
require_once("common.php"); ←追加
# lang_load call
$g_lang_strings = array();
user_api_keyを取得
TestLinkを開き「個人情報」を開く。一番下に
LOCALIZE: btn_apikey_generate ボタンをクリック
OCALIZE: user_api_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxx
クライアントプログラム変更
lib\api\sample_clients\ruby\clientSample.rb をエディタで開く
以下を変更
URL変更
# substitute your server URL Here
SERVER_URL = "http://qa/testlink_sandbox/api/xmlrpc.php"
上記のURLを変更する
例
# substitute your server URL Here
SERVER_URL = "http://localhost/testlink_beta/lib/api/xmlrpc.php"
※APIのパスがapi/xmlrpc.php→lib/api/xmlrpc.phpと変わっているので注意
user_api_keyセット
↓上記のuser_api_keyに書き換える
# substitute your Dev Key Here
client = TestlinkAPIClient.new("xxxxxxxxxxxxxxxxxxxxxxxxxxxx")
sayHelloメソッドを追加
元
class TestlinkAPIClient # substitute your server URL Here SERVER_URL = "http://localhost/testlink_beta/lib/api/xmlrpc.php" def initialize(dev_key) @server = XMLRPC::Client.new2(SERVER_URL) @devKey = dev_key end def reportTCResult(tcid, tpid, status) args = {"devKey"=>@devKey, "tcid"=>tcid, "tpid"=>tpid, "status"=>status} @server.call("tl.reportTCResult", args) end end
↓sayHelloメソッドを追加します
class TestlinkAPIClient # substitute your server URL Here SERVER_URL = "http://localhost/testlink_beta/lib/api/xmlrpc.php" def initialize(dev_key) @server = XMLRPC::Client.new2(SERVER_URL) @devKey = dev_key end def reportTCResult(tcid, tpid, status) args = {"devKey"=>@devKey, "tcid"=>tcid, "tpid"=>tpid, "status"=>status} @server.call("tl.reportTCResult", args) end def sayHello @server.call("tl.sayHello") end end
呼び出すメソッドを変更
result = client.reportTCResult(xxxx, xxxx, "f")
↓client.sayHelloに変更
#result = client.reportTCResult(xxxx, xxxx, "f")
result = client.sayHello
実行する
以下が返る
result was: Hello!