You can combine two or more existing queries into a new query using the Mark by Named Query dialog box. The new query can represent the union of the constituent queries (logical OR) or the intersection of the constituent queries (logical AND).
Combining two or more queries by union creates a new named query that marks all tests that would have been marked by running each query one after the other while retaining existing marks. Since Mark by Named Query clears existing marks before running a query, the only way to achieve this result is to create a new query that combines the constituent queries by union.
Suppose you have two queries, Query1 and Query2, that you want to combine by union.
|Developer: David||Developer: Jesse|
|Component: Searching||TestLevel: 2|
The new query created from the union of Query1 and Query2 will first mark those tests that match all the criteria in Query1 (Developer is David and Component is Searching) and then mark those tests that match all the criteria in Query2 (Developer is Jesse and TestLevel is 2).
Combining two or more queries by intersection creates a new named query that marks every test that has the criteria specified in all constituent queries.
For example, combining Query1 and Query2 by intersection would create a new query that comprised these criteria: Developer is David and Jesse, Component is Searching, and TestLevel is 2. In this case, the new query would not mark any tests, since it is impossible for a test to have two different values for the attribute Developer (unless Developer were defined as type Set under Windows). Use care when combining queries by intersection.