On Mon, Feb 2, 2015 at 11:06 AM, Konstantin Trunin
<
konst...@trunin.com> wrote:
> Hi.
> We have too big data set (examples section) in some test cases and we want
> to reduce execution time by checking only few random items for every test
> run.
The best way to do it is not to do it ;-)
If you are fine executing random examples, it means that the same
functionality is covered by more than one example. It is a test smell
and you should be thinking how you can split and group them. Examples
are fine to define rules and behaviour, but IMO examples should be
kept to a minimum in scenario outlines.
> Ideally it would be something like parametrized tag @Random(n) where is is %
> of examples that should be taken and executed.
> E.g. if we have 100 examples and I set @Random(15) then 15 random examples
> should be taken and executed.
> Could you please help me and clarify how to implement it?
If you want to execute part of the examples in a test suite that runs
on every checkin and a full suite overnight, you can have more than
one examples section annotated with different tags.
> I think I should create Hook, read tags.
> If it is a first time we process Scenario then read examples and shuffle
> them, save in some global storage together with counter.
> If it is not a first time then check that counter is < required number -
> then find random item from global storage and remove it from there (to not
> repeat examples) and process execution with this example.
> If we exceeded required number of executions then interrupt this Scenario
> Outline execution - and do it some how w/o error in report.
I don't see how this would work as Cucumber expands scenario outlines
in separate scenarios.
Paolo