Multiple tags for examples and filtering them

36 views
Skip to first unread message

Kamesh Velu

unread,
Apr 7, 2014, 2:56:42 PM4/7/14
to rs...@googlegroups.com
Hi
I have quite a few amount of test cases and i am looking for a way to create test suites that are derived by using tag filters. Any advice of how to implement this will be appreciated.

This is what i am trying to do

description 'Feature 1' do
  context 'Context 1' do
    it 'test case 1, run on all 3 platforms', :platform1, :platform2, :platform3, :smoke do
        steps1
        step2
    end

    it 'test case 2, runs only 2 platforms', :platform1, :platform3, :regression do
        steps1
        step2
    end

    it 'test case 3, run only on 2 platforms', :platform1, :platform2, :smoke, :regression do
        steps1
        step2
    end
  end

  context 'context 2' do
    it 'test case 4, runs only on one platforms', :platform1, :smoke, :regression do
        steps1
        step2
    end

    it 'test case 5, run on all 3 platforms', :platform1, :platform2, :platform3, :smoke  do
        steps1
        step2
    end
  end
end



I want to create filter like this

All test cases that can run on platform 1: filter_run_including :platform1
All test cases that can run on platform 2: filter_run_including :platform2
All test cases that can run on platform 3: filter_run_including :platform3

All smoke test cases for platform 1: filter_run_including :platform1 AND filter_run_including :smoke
All smoke test cases for platform 2: filter_run_including :platform2 AND filter_run_including :smoke
All smoke test cases for platform 3: filter_run_including :platform3 AND filter_run_including :smoke

All regression test cases for platform 1: filter_run_including :platform1 AND filter_run_including :regression
All regression test cases for platform 2: filter_run_including :platform2 AND filter_run_including :regression
All regression test cases for platform 3: filter_run_including :platform3 AND filter_run_including :regression

Thanks


    

Kamesh Velu

unread,
Apr 7, 2014, 6:40:11 PM4/7/14
to rs...@googlegroups.com
This worked!!! 

All i have to do add treat_symbols_as_metadata_keys_with_true_values = true in my config

Knock

unread,
Nov 3, 2015, 5:24:22 PM11/3/15
to rspec
Hi Kamesh,

I'm working toward a filtering scheme that would require multiple tags to match in order to trigger, similar to your 'platform' and 'smoke' cases.  I'm curious where you defined your cases.  Did you use a separate configuration file or add lines to the spec_helper?

I'd like to be able to write filters on the fly, but the --tag options available to the command line obviously run everything for each tag rather than blocks that match multiple tags only.

Thanks!

Mike
Reply all
Reply to author
Forward
0 new messages