test_link_client

Description

TODO: Description

Features

Examples

require 'test_link_client'
require 'text-table'

server = "http://testlink"
dev_key = "90b7941411928ae0a84d19f365a01a63"

tl = TestLinkClient.new(server, dev_key)
project_id = tl.test_project_id "My Project"            # => "172"
test_plans = tl.find_test_plans(project_id, /Hello/)    # => 

builds_for_test_plans = test_plans.collect do |test_plan|
  t.builds_for_test_plan(test_plan["id"])
end
builds_for_test_plans.flatten!

results = {}
builds.each do |build|
  results[:pass] = 0
  results[:failed] = 0
  results[:blocked] = 0
  results[:skipped] = 0

  # get test cases from a build, by build id
  # for each test case, call #last_execution_result
  puts "Build: #{build["name"]} (#{build["id"]})"
  puts "TestPlan ID: #{build["testplan_id"]}"

  test_cases = tl.test_cases_for_test_plan(build["testplan_id"],
      { "buildid" => build["id"] })

  test_cases.each_value do |test_case|
    case test_case["exec_status"]
    when "p"
      results[:pass] += 1
    when "f"
      results[:failed] += 1
    when "b"
      results[:blocked] += 1
    when "s"
      results[:skipped] += 1
    end
  end

  overall[:pass] += results[:pass]
  overall[:failed] += results[:failed]
  overall[:blocked] += results[:blocked]
  build_total = results[:pass] + results[:failed] + results[:blocked] + results[:skipped]
  overall_rate = "%2.2f" % (overall[:pass] * 100 / (overall[:pass] + overall[:failed]).to_f)
  overall_rate_plus_blocked = "%2.2f" % (overall[:pass] * 100 / (overall[:pass] + overall[:failed] + overall[:blocked]).to_f)

  result_array = [
    ['Passed', 'Failed', 'Blocked', 'Skipped', 'TOTAL', 'Overall %', 'Overall % (+B)'],
    [results[:pass], results[:failed], results[:blocked], results[:skipped],
      build_total, overall_rate, overall_rate_plus_blocked]
  ]
  puts result_array.to_table(:first_row_is_head => true)
  puts "(#{overall[:pass]}/#{overall[:failed]}/#{overall[:blocked]})"
end

Requirements

General notes: TestLinkAPI docs: testlink.org/api/phpdoc_generated/TestlinkAPI/TestlinkXMLRPCServer.html

Getting it all running:

  1. Need to enable automation on the testlink config file:

    config.inc.php => $tlCfg->api->enabled = TRUE;
  2. The user that needs to run the automated tests needs to generate a API key

that will be used in creating the connection. This is accomplished by logging in to testlink and going to “Personal -> API Key -> Generate a new key”.

Install

$ gem install test_link_client

Copyright

Copyright © 2011 sloveless

See LICENSE.txt for details.