Skip to content

Test Case Management

vicwin edited this page Aug 11, 2012 · 10 revisions

While feature file and scenario are good way to refere a test caes, it becomes more difficult to communicate to other when the number of test cases and projects grows. Warden provides a way to assign Cucumber feature and scenario a unique ID, so they can be reference and run in a cleaner way.

#Test Case to Scenario Mapping Different scenarios( distinguished by the scenario's name) in a feature will have a different ID. This ID is unique to all the projects under Warden. We can run the scenario alone by giving it's ID using Warden command line utility(./bin/Warden.rb).

##Automatic Scenario Registration

  • Set ENV['WARDEN_ENABLE_TEST_CASE_REGISTRATION'] = "1" in $WARDEN_HOME/config/env.rb to enable this feature

Once this feature is enabled, the scenario will register and update itself every time it runs. As of now, we have to run all the scenario at least once to register them(pass and fail are ignore in the process). the mapping file is stored under WARDEN_HOME/etc/test_case_map.yml and the back up map is store under $WARDEN_HOME/etc/test_case_map.yml.bak.

Note: Right now the registration process does not support parallel execution, so please don't run multiple instances or Cucumber when you are enabled the registration feature

Example of the file:

--- 
:next_available_tc_id: 36
:tc_map: 
  1: 
  - BB.ca Web BG
  - Dealzone.feature
  - The user should be able to select featured products
  - "4"
  2: 
  - BB.ca Web BG
  - Search.feature
  - Reference Code search works
  - "10"
  3: 
  - BB.ca Web BG
  - Search.feature
  - Keyword search should work
  - "18"
...

##Warden Command Line Once the scenario is registered in Warden, it can be executing through Warden command line

  • Running a Scenario
wb-preset:bin victor$ $WARDEN_HOME/bin/warden.rb run --tc_id_list 1
cucumber '/Users/victor/work/warden_fw/projects/BB.ca Web BG/features/Dealzone.feature'  -n  "The user should be able to select featured products"
Feature: Users should be able to interact with the Deal Zone tab

  @ui
  Scenario: The user should be able to select featured products                                             # /Users/victor/work/warden_fw/projects/BB.ca Web BG/features/Dealzone.feature:4
    Given user is using page objects to access the default test target environment for the test application # /Users/victor/work/warden_fw/lib/lib_steps.rb:43
    And the user clicks the Deal Zone tab                                                                   # /Users/victor/work/warden_fw/projects/BB.ca Web BG/features/Tabs.rb:39
    Then ensure the user can select the first featured product                                              # /Users/victor/work/warden_fw/projects/BB.ca Web BG/features/Dealzone.rb:5
    And ensure the user can select the second featured product if present                                   # /Users/victor/work/warden_fw/projects/BB.ca Web BG/features/Dealzone.rb:15
    And ensure the user can select the third featured product if present                                    # /Users/victor/work/warden_fw/projects/BB.ca Web BG/features/Dealzone.rb:27
    And ensure the user can select More Products to Consider if present                                     # /Users/victor/work/warden_fw/projects/BB.ca Web BG/features/Dealzone.rb:39

1 scenario (1 passed)
6 steps (6 passed)
0m54.638s
  • Running multiple scenario uses a comma separated list $WARDEN_HOME/bin/warden.rb run --tc_id_list 10,4,9
  • Or putting all the IDs in a file "demo.suite" and run $WARDEN_HOME/bin/warden.rb run --file ./demo.suite
#demo.suite
10
4
9
  • Run $WARDEN_HOME/bin/warden.rb run -h for more information about using the command line to run scneario

##Browsing Registered Test Cases Warden command line also provides ways to look up the scenario information like project name , feature name by its ID or looks up its ID by feature file name, project name and scenario name

Note: project name, feature name and scenario naming is matched using simple fuzzy matching, to enable strick matching use the --strict_mathcing flag

  • Show all the registered test cases $WARDEN_HOME/bin/warden.rb show
TC_ID	Project Name	Feature Name	Scenario Name	Line Number
5	BB.ca Web BG	Dealzone.feature	The user should be able to select featured products	4
6	BB.ca Web BG	Search.feature	Reference Code search works	10
7	BB.ca Web BG	Search.feature	Keyword search should work	18
4	BB.ca Web BG	Search.feature	User can interact with their recent searches	27
10	BB.ca Web BG	test_1/TopRated.feature	The user should be able to select featured products on the top rate page	4
11	BB.ca Web BG	UIVerification.feature	English Landing page has correct active tab and basic layout	4
...
  • Find all the scenario by project name $WARDEN_HOME/bin/warden.rb show -p <project_name>
wb-preset:bin victor$ ./warden.rb show -p climate
TC_ID	Project Name	Feature Name	Scenario Name	Line Number
9	climate	risk_report.feature	my 2nd scenario	13
22	climate	risk_report.feature	my first scenario	5
  • Find all the scenario by scenario name $WARDEN_HOME/bin/warden.rb show -s <scenario_name>
wb-preset:bin victor$ ./warden.rb show -s 'Computer Recommendation pages are correct'
TC_ID	Project Name	Feature Name	Scenario Name	Line Number
28	BB.ca Web BG	recommendationpage.feature	Computer Recommendation pages are correct	4
  • For more information look at $WARDEN_HOME/bin/warden.rb show -h

##Test Case Export to Warden Web To import the test case from yaml file to Warden Web DB, the step is simple, run the following rake task:

cd $WARDEN_WEB_HOME
rake registration:run
Test case 'ISA:ui_verification.feature:| "2" | "Whats Changed Between 2nd and 3rd Gen?" |' at './ISA/ui_verification.feature' has been registered into DB.
Test case 'Costco BG:BuyNowLinks.feature:| "LAPTOPS & ULTRABOOKS" | "Browse Laptops & Ultrabooks" |' at './Costco BG/BuyNowLinks.feature' has been registered into DB.
Test case 'Costco BG:BuyNowLinks.feature:| "DESKTOPS & ALL-IN-ONES" | "Browse Desktops & All-In-Ones" |' at 
...
...