Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
pkg
reports
coverage
*.gem
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testlink-api-client
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-2.6.3
1 change: 0 additions & 1 deletion .rvmrc

This file was deleted.

20 changes: 18 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This gem provides an endpoint for TestLink Remote API

== Installation
In a shell, just run:
$ gem install teslink-api-client
$ gem install testlink-api-client

== How to use it

Expand All @@ -18,4 +18,20 @@ To use this library you just need to require the gem:
tl.getProjects #Will return an Array of TestLink::Objects::Project

== Bug Reporting
If you find any bug, please feel free to report it at https://github.com/floreal/testlink-api-client/issues
If you find any bug, please feel free to report it at https://github.com/floreal/testlink-api-client/issues

== Contribution

1. Fork on Github
2. `gem install rspec`
3. `gem install autotest-growl`
4. `gem install autotest`
5. `gem install cucumber`
6. `gem install simplecov`
7. `rspec spec`
8. In forked repo, create feature branch

== Build

gem build testlink-api-client.gem
gem install ./testlink-api-client-version.gem
18 changes: 9 additions & 9 deletions features/step_definitions/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@

Then /^A response error exception is raised with a message "([^"]*)"$/ do |message|
fail "Received a non error response \"#{@result}\" when expecting an error message: #{message}" if @error.nil?
@error.class.should < TestLink::Exceptions::Exception
@error.message.should == message
expect(@error.class).to be < TestLink::Exceptions::Exception
expect(@error.message).to eq message
end

Then /^I get status "([^"]*)" for "([^"]*)" with additionalInfo "([^"]*)" and message "([^"]*)"$/ do |status, operation, info, message|
fail "Received an error \"#{@error}\" when expecting a success" unless @error.nil?
@result.count.should == 1
expect(@result.count).to eq 1
returned_status = @result.first
returned_status.should be_instance_of TestLink::Objects::Status
returned_status.status.should == string2boolean(status)
returned_status.operation.should == operation
returned_status.additional_info.should == info
returned_status.message.should == message
expect(returned_status).to be_instance_of TestLink::Objects::Status
expect(returned_status.status).to eq string2boolean(status)
expect(returned_status.operation).to eq operation
expect(returned_status.additional_info).to eq info
expect(returned_status.message).to eq message
end

Then /^I get this node list:$/ do |table|
@result.should == table.hashes.map { |row|
expect(@result).to eq table.hashes.map { |row|
node = TestLink::Objects::Node.new
node.id = row['id'].to_i if
node.parent_id = row['parent_id'].to_i
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/get_projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
end

Then /^I get this Project list:$/ do |table|
@result.should == table.hashes.map { |row|
expect(@result).to eq table.hashes.map { |row|
project = TestLink::Objects::Project.new
project.id = row['id'].to_i
project.notes = row['notes'].to_s
Expand Down
2 changes: 2 additions & 0 deletions lib/test_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
require 'test_link/command'
require 'test_link/adapters'
require 'test_link/exceptions'
require 'test_link/objects'
require 'test_link/enums'

module TestLink
end
11 changes: 8 additions & 3 deletions lib/test_link/api_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@
module TestLink
class ApiLink
attr_accessor :key
attr_reader :client, :url
attr_reader :client, :url, :version
@@remote_methods = {}
@@adapters = {}
def initialize(url, key)
def initialize(url, key, version = :v0)
@url = url
@key = key
@version = version
@client = XMLRPC::Client.new2 self.api_url
end

def api_url()
@url + '/lib/api/xmlrpc.php'
if @version == :v1
@url + '/lib/api/xmlrpc/v1/xmlrpc.php'
else
@url + '/lib/api/xmlrpc.php'
end
end

def self.remote_method(klass)
Expand Down
4 changes: 4 additions & 0 deletions lib/test_link/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
require 'test_link/command/get_test_suites_for_test_suite'
require 'test_link/command/get_test_suite_by_id'
require 'test_link/command/create_test_case'
require 'test_link/command/report_test_case_result'
require 'test_link/command/get_test_cases_for_test_suite'
require 'test_link/command/get_project_test_plans'
require 'test_link/command/get_latest_build_for_test_plan'

module TestLink
module Command
Expand Down
29 changes: 29 additions & 0 deletions lib/test_link/command/get_latest_build_for_test_plan.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file is part of testlink-api-client.
#
# testlink-api-client is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# testlink-api-client is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with testlink-api-client. If not, see <http://www.gnu.org/licenses/>.

require 'test_link/command/base'
require 'test_link/adapters/node_adapter'

module TestLink
module Command
class GetLatestBuildForTestPlan < Base
remote_method

argument :testplanid, :mandatory => true

adapt_with Adapters::NodeAdapter
end
end
end
29 changes: 29 additions & 0 deletions lib/test_link/command/get_project_test_plans.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file is part of testlink-api-client.
#
# testlink-api-client is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# testlink-api-client is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with testlink-api-client. If not, see <http://www.gnu.org/licenses/>.

require 'test_link/command/base'
require 'test_link/adapters/node_adapter'

module TestLink
module Command
class GetProjectTestPlans < Base
remote_method

argument :testprojectid, :mandatory => true

adapt_with Adapters::NodeAdapter
end
end
end
31 changes: 31 additions & 0 deletions lib/test_link/command/get_test_cases_for_test_suite.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This file is part of testlink-api-client.
#
# testlink-api-client is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# testlink-api-client is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with testlink-api-client. If not, see <http://www.gnu.org/licenses/>.

require 'test_link/command/base'
require 'test_link/adapters/node_adapter'

module TestLink
module Command
class GetTestCasesForTestSuite < Base
remote_method

argument :testsuiteid, :mandatory => true
argument :deep
argument :details

adapt_with Adapters::NodeAdapter
end
end
end
39 changes: 39 additions & 0 deletions lib/test_link/command/report_test_case_result.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is part of testlink-api-client.
#
# testlink-api-client is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# testlink-api-client is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with testlink-api-client. If not, see <http://www.gnu.org/licenses/>.

require 'test_link/command/base'
require 'test_link/adapters/status_adapter'

module TestLink
module Command
class ReportTCResult < Base
remote_method

argument :testcaseid, :mandatory => true
argument :testplanid, :mandatory => true
argument :status, :mandatory => true
argument :buildid
argument :buildname
argument :notes
argument :guess
argument :bugid
argument :platformid
argument :platformname
argument :customfields

adapt_with Adapters::StatusAdapter
end
end
end
21 changes: 21 additions & 0 deletions lib/test_link/enums.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file is part of testlink-api-client.
#
# testlink-api-client is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# testlink-api-client is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with testlink-api-client. If not, see <http://www.gnu.org/licenses/>.

require 'test_link/enums/valid_status_list'

module TestLink
module Enums
end
end
28 changes: 28 additions & 0 deletions lib/test_link/enums/valid_status_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file is part of testlink-api-client.
#
# testlink-api-client is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# testlink-api-client is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with testlink-api-client. If not, see <http://www.gnu.org/licenses/>.

module TestLink
module Enums
module ValidStatusList
FAILED = 'f'
BLOCKED = 'b'
PASSED = 'p'
NOT_RUN = 'n'
NOT_AVAILABLE = 'x'
UNKNOWN = 'u'
ALL = 'a'
end
end
end
5 changes: 5 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
#
# You should have received a copy of the GNU General Public License
# along with testlink-api-client. If not, see <http://www.gnu.org/licenses/>.
require 'rspec/expectations'
require 'simplecov'
SimpleCov.start do
enable_coverage :branch
end

module RSpec::Matchers
def attribute_provided? object, attribute
Expand Down
4 changes: 2 additions & 2 deletions spec/test_link/adapters/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
end

it "manages responses" do
@adapter.should provide :response
expect(@adapter).to provide :response
end

it "raises an exception when an error code is detected in the response" do
Expand All @@ -45,7 +45,7 @@
def @adapter.adapt_row row
end
@adapter.response = [{'name' => 'a'}, {'name' => 'b'}]
@adapter.response.each { |row| @adapter.should_receive(:adapt_row).with(row) }
@adapter.response.each { |row| allow(@adapter).to receive(:adapt_row).with(row) }
@adapter.adapt
end

Expand Down
10 changes: 5 additions & 5 deletions spec/test_link/adapters/node_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
end

it "inherits from TestLink::Adapters::Base" do
TestLink::Adapters::NodeAdapter.should < TestLink::Adapters::Base
expect(TestLink::Adapters::NodeAdapter).to be < TestLink::Adapters::Base
end

it "should know how to adapt a single row of a response" do
Expand All @@ -34,7 +34,7 @@
"node_table" => node.table = "testsuites",
"name" => node.name = "First Testsuite"}

@adapter.adapt_row(row).should == node
expect(@adapter.adapt_row(row)).to eq node
end

it "should should adapt raw response to Project objects" do
Expand All @@ -56,7 +56,7 @@
"name" => node2.name = "Second Testsuite"}]

@adapter.response = response
@adapter.adapt.should == [ node1, node2 ]
expect(@adapter.adapt).to eq [ node1, node2 ]
end

describe "workaround unexpected messages form" do
Expand All @@ -81,7 +81,7 @@
"parent_id"=> (node2.parent_id = 2).to_s}}

@adapter.response = response
@adapter.adapt.should == [ node1, node2 ]
expect(@adapter.adapt).to eq [ node1, node2 ]
end

it 'allows to receive a single node out of an array' do
Expand All @@ -96,7 +96,7 @@
"parent_id" => (node.parent_id = 2).to_s}

@adapter.response = response
@adapter.adapt.should == [ node ]
expect(@adapter.adapt).to eq [ node ]
end
end
end
Loading