Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combinatorial testing with Cucumber

I have a scenario outline that has two different variables. One variable has about 20 different values and the other has 3.

I need to be able to test every single combination and I need each in a separate scenario since they must be tested independently.

Currently, I just write it out by hand(they are integers in the example but not in my test):

Scenario Outline: Test my stuff
Given first var is <var_a>
And second var is <var_b>
When I do stuff
Then good stuff should happen

Examples:
| var_a | var_b |
| 1     | 1     |
| 1     | 2     |
| 1     | 3     |
| 2     | 1     |
| 2     | 2     |
etc...

Question: Is there a way to run this where every combination doesn't have to be written out? The variables are bound to change in size and content later on and I would prefer to have a single data structure to deal with.

like image 729
juan2raid Avatar asked May 03 '11 16:05

juan2raid


People also ask

What is combinational testing?

Combinatorial testing is a testing technique in which multiple combinations of the input parameters are used to perform testing of the software product. The aim is to ensure that the product is bug-free and can handle different combinations or cases of the input configuration.

What is the main idea of combinatorial testing?

The main idea behind combinatorial testing is that software bugs are discovered more effectively when it is tested using combinations of inputs or configurations.

How does combinatorial testing perform in the real world an empirical study?

By focusing on the interactions between different factors of a system, CT shows its potential for detecting faults, especially those that can be revealed only by the specific combinations of values of multiple factors (multi-factor faults).

When should I use cucumber framework?

The decision to use Cucumber or a unit testing framework is depending on the cooperation with the business. If they have opinions about the behaviour, then use Cucumber. If they are indifferent, use a unit testing framework. There are no hard rules here.


1 Answers

Scenario: Test my stuff
Given first var combinations is @var_a_combos
Given second var combinations is @var_b_combos
When I run every combination
Then good stuff should happen
  • @var_a_combos and @var_b_combos are an Enumerable that contains every different possibility for that type.
  • The When I run every combination will iterate over both variables and test every single combination. Instead of using an assertion, it will instead create a @results(String) variable that will list any failures and their required debugging data.
  • The Then good stuff should happen will run the code @results.should eql "" to determine whether the test case passed/failed.

The purpose of using a String variable to hold the results(instead of an assertion) is to ensure that testing does not stop when the first failure is encountered.

I really don't like this solution but it is the best I could come up with so far. I appreciate the other answers but this testing really is integration testing and I really do need to test every combination.

If anyone posts further answers I will review them and change the accepted answer if I think it is better.

like image 55
juan2raid Avatar answered Oct 17 '22 00:10

juan2raid