-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from ErikDahlinghaus/issue-8/capture-tags-on-co…
…ntext-blocks Issue-8: Allows labeling context blocks
- Loading branch information
Showing
6 changed files
with
95 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
- [x] Create dynamic test run and update test results in it | ||
- [x] Update multi-testrail cases from a single automation scenario | ||
- [x] Static status comments on all the scenarios | ||
- [x] Support for RSpec `shared examples` | ||
|
||
## Installation | ||
|
||
|
@@ -30,7 +31,7 @@ $ gem install testrail-rspec | |
require 'testrail-rspec' | ||
``` | ||
|
||
## #Usage outline | ||
## Usage outline | ||
|
||
#### Update one case at a time | ||
Prefix TestRail Case ID on start of your rspec scenario; say, `C845` | ||
|
@@ -54,8 +55,7 @@ Prefix TestRail Case ID on start of your rspec scenario; say, `C845` | |
``` | ||
|
||
#### Update multi-cases at a time | ||
|
||
Prefix multiple TestRail Case IDs on start of your rspec scenario; say, `C845 C845 your scenario description` | ||
Prefix multiple testrail case id(s) on start of your rspec scenario; say, `C845 C845 your scenario description` | ||
|
||
```ruby | ||
describe 'Verify Google Home Page' do | ||
|
@@ -75,38 +75,68 @@ Prefix multiple TestRail Case IDs on start of your rspec scenario; say, `C845 C8 | |
end | ||
``` | ||
|
||
#### TestRail details | ||
|
||
Provide TestRail details by creating a config file, `testrail_config.yml` in the project parent folder | ||
#### Use context blocks to update cases | ||
`Context blocks` with testrail case id(s) to make use of `Shared Examples` | ||
|
||
> With existing `Test Run` | ||
```ruby | ||
shared_examples 'log in' do | ||
it 'logs in' | ||
end | ||
|
||
- Add testrail details (`url`, `user`, `password`, and `run_id`) | ||
- `run_id` is the dynamically generated id from your testrail account (say, `run_id: 111`) | ||
shared_examples 'log out' do | ||
it 'logs out' | ||
end | ||
|
||
```yaml | ||
testrail: | ||
url: https://your_url.testrail.io/ | ||
user: [email protected] | ||
password: ****** | ||
run_id: 111 | ||
``` | ||
describe 'User login' do | ||
context 'Regular user' do | ||
let(:user) { create(:regular_user) } | ||
context 'C845 single case' do | ||
include_examples 'log in' | ||
end | ||
|
||
> Create dynamic `Test Run` and update results | ||
context 'C847' do | ||
include_examples 'log out' | ||
end | ||
end | ||
|
||
- Add testrail details following `project_id` and `suite_id` | ||
- `project_id` and `suite_id` are the dynamically generated id from your testrail account | ||
- `run_id` is optional here; you may (or) may not have it in this case | ||
context 'Admin user' do | ||
let(:user) { create(:admin_user) } | ||
context 'C850 C853 multi cases' do | ||
include_examples 'log in' | ||
end | ||
|
||
```yaml | ||
testrail: | ||
url: https://your_url.testrail.io/ | ||
user: [email protected] | ||
password: ****** | ||
project_id: 10 | ||
suite_id: 110 | ||
context 'nothing to update in test-rail' do | ||
include_examples 'log out' | ||
end | ||
end | ||
end | ||
``` | ||
|
||
#### Configuration | ||
|
||
1. Create a config file, `testrail_config.yml` in the project's parent folder | ||
2. Enter the testrail details based on demand | ||
3. To execute tests against the existing `Test Run`, | ||
```yaml | ||
testrail: | ||
url: https://your_url.testrail.io/ | ||
user: [email protected] | ||
password: ****** | ||
run_id: 111 | ||
``` | ||
Here, `run_id` is the dynamically generated id from your testrail account (say, `run_id: 111`) | ||
|
||
4. To create a dynamic `Test Run` and to update results, | ||
```yaml | ||
testrail: | ||
url: https://your_url.testrail.io/ | ||
user: [email protected] | ||
password: ****** | ||
project_id: 10 | ||
suite_id: 110 | ||
``` | ||
Here, `project_id` and `suite_id` are the dynamically generated id from your testrail account; `run_id` is optional in this case. | ||
|
||
#### Hooks | ||
|
||
Update the results through `Hooks` on end of each test | ||
|
@@ -116,7 +146,7 @@ config.after(:each) do |scenario| | |
end | ||
``` | ||
**Is there a demo available for this gem?** | ||
**Is there any demo available for this gem?** | ||
Yes, you can use this `capybara` demo as an example, https://github.com/prashanth-sams/testrail-rspec | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
task :test do |_task| | ||
system "rspec spec/features/*_spec.rb" | ||
system "rspec spec/features/google_search_spec.rb" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
require 'spec_helper' | ||
|
||
feature 'Verify Google Home Page' do | ||
before do | ||
@app.google_home.load | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
shared_examples 'pass' do | ||
it 'pass' do | ||
expect(true).to be true | ||
end | ||
end | ||
|
||
shared_examples 'fail' do | ||
it 'fail' do | ||
expect(false).to be true | ||
end | ||
end | ||
|
||
describe 'Generic scenarios' do | ||
context 'A regular user can' do | ||
context 'C845' do | ||
include_examples 'pass' | ||
end | ||
|
||
context 'C847' do | ||
include_examples 'fail' | ||
end | ||
end | ||
|
||
context 'Complex scenarios' do | ||
context 'C850 C853 multi cases' do | ||
include_examples 'pass' | ||
end | ||
|
||
context 'Not going to update in test-rail' do | ||
include_examples 'fail' | ||
end | ||
end | ||
end |