Skip to content

Commit

Permalink
Merge pull request #5 from prashanth-sams/update
Browse files Browse the repository at this point in the history
update multi cases
  • Loading branch information
prashanth-sams authored Dec 17, 2019
2 parents db30838 + 440c92f commit 3e3d230
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Gemfile.lock
.DS_Store
**/.DS_Store
.byebug_history
.idea/
.idea/
testrail-rspec-*
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
### Features
- [x] Update test results in the existing test run
- [x] Create dynamic test run and update test results in it
- [x] Create dynamic tlts in the existing test run
- [x] Update multi-testrail cases from a single automation scenario

## Installation

Expand All @@ -30,8 +31,7 @@ require 'testrail-rspec'

## #Usage outline

#### Sync Case ID

#### Update one case at a time
Prefix TestRail Case ID on start of your rspec scenario; say, `C845`

```ruby
Expand All @@ -52,6 +52,28 @@ Prefix TestRail Case ID on start of your rspec scenario; say, `C845`
end
```

#### Update multi-cases at a time

Prefix multiple TestRail Case IDs on start of your rspec scenario; say, `C845 C845 your scenario description`

```ruby
describe 'Verify Google Home Page' do

scenario 'C847 C846 C845 verify the Google home page' do
expect(page).to have_content('Google')
end

scenario 'C848 C849 verify the Google home page to fail' do
expect(page).to have_content('Goo gle')
end

scenario 'verify the Google home page to fail' do
expect(page).to have_content('Goo gle')
end

end
```

#### TestRail details

Provide TestRail details by creating a config file, `testrail_config.yml` in the project parent folder
Expand Down
14 changes: 10 additions & 4 deletions lib/testrail-rspec/update-testrails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ def initialize(scenario)
def upload_result

response = {}
case_id = @scenario.metadata[:description].split(' ').first.scan(/\d+/).first rescue nil

case_list = []
@scenario.metadata[:description].split(' ').map do |e|
val = e.scan(/\d+/).first
next if val.nil?
case_list << val
end

return if case_list.empty?

if (@scenario.exception) && (!@scenario.exception.message.include? 'pending')
status_id = get_status_id 'failed'.to_sym
Expand All @@ -40,13 +48,11 @@ def upload_result
@run_id = @@run_id rescue @@run_id = nil unless @config['run_id']
@run_id = @@run_id = client.create_test_run("add_run/#{@config['project_id']}", { "suite_id": @config['suite_id']}) if @run_id.nil?

if case_id && @run_id
case_list.map do |case_id|
response = client.send_post(
"add_result_for_case/#{@run_id}/#{case_id}",
{ status_id: status_id, comment: message }
)
else
raise 'unable to get case id or run id'
end

response
Expand Down
2 changes: 1 addition & 1 deletion lib/testrail-rspec/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TestrailRspec
VERSION = '0.1.3'.freeze
VERSION = '0.1.4'.freeze
end
8 changes: 8 additions & 0 deletions spec/features/google_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@
skip "skipping this test"
end

scenario 'C856 C859 C860 verify the Google home page to skip' do
expect(page).to have_content('Goo gle')
end

scenario 'verify the Google home page to skip' do
expect(page).to have_content('Google')
end

end

0 comments on commit 3e3d230

Please sign in to comment.