Enforced combination?

18 views
Skip to first unread message

Daniel Brahneborg

unread,
Feb 23, 2016, 1:17:37 PM2/23/16
to Tcases Forum
Is there a way to ensure that a certain value combination is used as a test?
That is, the exact opposite of whenNot. Other combinations are ok, but a few of them must always be present.
For example, my program supports HTTP and SMTP, and can send Latin-1 and UTF-8. I know that SMTP has problems with UTF-8, so I want to make sure that that combination is selected.
Are there any ways to do that, other than creating an "fake" output file containing this combination?

Kerry Kimbrough

unread,
Feb 24, 2016, 11:02:08 AM2/24/16
to Tcases Forum
Yes, there are lots of way you can ensure that a specific combination of input values appears in a generated test case.

For example, suppose you have something like the following in your input definition.

<Var name="protocol">
   
<Value name="SMTP"/>
   
<Value name="HTTP"/>
</Var>
<Var name="charSet">
   
<Value name="Latin-1"/>
   
<Value name="UTF-8"/>
</Var>

Probably the best technique is to create a generator definition file (<project>-Generators.xml) that demands all pairs of protocol and charSet values. For example:

<Generators>
 
<TupleGenerator function="*">
   
<Combine tuples="2">
     
<Include var="protocol"/>
     
<Include var="charset"/>
   
</Combine>
 
</TupleGenerator>
</Generators>

 This will create at least one test case that combines protocol=SMTP and charSet=UTF-8, as well as other combinations that might expose other problems due to interactions between these variables.

Alternatively, if you're not very concerned about interactions among other combinations, you could use a simple constraint that always pairs protocol=SMTP with charSet=UTF-8. The following example constrains the combination in one direction, but you could choose to constrain it in the other direction instead. This limits other combinations, but it might be OK for your situation.

<Var name="protocol">
   
<Value name="SMTP" property="smtp"/>
   
<Value name="HTTP"/>
</Var>
<Var name="charSet">
   
<Value name="Latin-1"/>
   
<Value name="UTF-8" when="smtp"/>
</Var>


Daniel Brahneborg

unread,
Feb 27, 2016, 3:42:23 AM2/27/16
to Tcases Forum
Thanks. I went with the Combine tuples="2" version.

For my protocol/charset situation, it seemed reasonable to ensure that I got full coverage.

The variant where one combination is forced, while other combinations are still allowed, got too theoretical. It was an assignment on a course about testing, but I can't find any real world situations where it would be worth the trouble.

Regards,
/Daniel

Reply all
Reply to author
Forward
0 new messages