オールペア法テストケース作成ツール(PICT)と TestLink の連携
ALLPAIRS Test Case Generation Tool と TestLink を連携させているツール があって、それに手を加えているもの があった。
ALLPAIRS Test Case Generation Tool で制約条件を記述する方法がわからなかったので、PICT の結果を TestLink と連携できるように、適当に手を加えてみた。
このデータを PICT にかけると
地域: 東京, 神奈川, 埼玉, 千葉 性別: 男, 女 時間帯: 昼, 夕方, 夜 オプション1: あり, なし オプション2: あり, なし
こうなるので
地域 性別 時間帯 オプション1 オプション2 千葉 男 昼 あり なし 埼玉 男 夕方 なし あり 埼玉 女 昼 あり あり 千葉 女 夜 なし あり 神奈川 女 昼 なし なし 埼玉 男 夜 あり なし 神奈川 男 夜 あり あり 東京 男 昼 あり なし 東京 女 夕方 なし あり 神奈川 男 夕方 あり なし 東京 男 夜 なし あり 千葉 女 夕方 なし あり
allpairs2testcase.rb にかけて xml を出力、TestLink へインポートするとこんな感じ。
allpairs2testcase.rb をいじったもの。
ソース公開のお作法が分からなかったので、そのまま。
garyo さんの testlinkjp allpairs2testcase 0.02 にあてるパッチとして出力してみました。
shimauchi さんの変更も含んでいます。
--- testlinkjp_allpairs2testcase_0.02\allpairs2testcase.rb Mon Oct 01 14:22:11 2007 +++ allpairs2testcase.rb Mon Sep 28 20:03:59 2009 @@ -11,29 +11,29 @@ require 'csv2testcace' class ApTestcase - attr_accessor :items,:testcase + attr_accessor :items,:testcase,:expectedResult @items @testcase + @expectedResult + @@t = 0 def initialize @items=[] @testcase = [] + @expectedResult = "" end def print s="<TABLE>" - s=s + "<TR>" - for i in 0..@items.size-2 + for i in 0..@items.size-1 + s=s + "<TR>" s=s+"<TD>#{@items[i].split}</TD>" - end - s=s + "</TR>" - s=s + "<TR>" - for i in 0..@testcase.size-2 s=s+"<TD>#{@testcase[i].split}</TD>" + s=s + "</TR>" end - s=s + "</TR>" s=s + "</TABLE>" end def getTitle - t=@testcase[0] + @@t = @@t + 1 + @@t.to_s end end class AllpairsTestcase @@ -48,42 +48,54 @@ attr_accessor :allpairsTestcase @allpairsTestcase @csv2testcase + @details + @summary def initialize @allpairsTestcase=AllpairsTestcase.new @csv2testcase=Csv2testcase.new + @details="" + @summary="" end def readFile(infile) f = File.open(infile,"r") + # get a label line s=f.gets - s=f.gets - s=f.gets + #puts Kconv.kconv(s, Kconv::SJIS, in_code = Kconv::EUC) items=s.split("\t") + useExpRes = false + if items.last.chomp == "ExpectedResult" then + items.pop + useExpRes = true + end s=f.gets - while s !="\n" + while s !=nil tc=ApTestcase.new tc.items=items - tc.testcase=s.split("\t") + #puts Kconv.kconv(s, Kconv::SJIS, in_code = Kconv::EUC) + t=s.split("\t") + tc.expectedResult = t.pop if useExpRes + tc.testcase = t @allpairsTestcase.testcase << tc s=f.gets end end - def initTestSuite(name,details) + def initTestSuite(name,details) @csv2testcase.initTestSuite(name,details) - end - def convXML(name_prefix="Test case No.",summary_prefix="",steps_prefix="",expectedresults_prefix="") + end + def convXML(name_prefix="Test case No.",summary_prefix=@summary,steps_prefix="",expectedresults_prefix="") @allpairsTestcase.testcase.each{|tc| - @csv2testcase.addTestcase(name_prefix + tc.getTitle,summary_prefix + tc.print,steps_prefix + tc.print,expectedresults_prefix) + @csv2testcase.addTestcase(name_prefix + tc.getTitle,summary_prefix,steps_prefix + tc.print,expectedresults_prefix + tc.expectedResult) } end def writeFile(outfile) @csv2testcase.writeFile(outfile) end def main(infile,outfile) - readFile(infile) - initTestSuite(infile,"") + readFile(infile) + initTestSuite(infile,@details) convXML - writeFile(outfile) + writeFile(outfile) end end