gauge icon indicating copy to clipboard operation
gauge copied to clipboard

Support for fine grain control over parallel vs serial specs.

Open hkang1 opened this issue 4 years ago • 9 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Looking to be able to have specs run at the end of all the parallelizable specs, in order to have specs that can test cleanup and teardown. Other scenarios include running certain serial specs followed by several parallel specs, then back to serial, back to parallel, etc. The steps approach will give the test writers the ability to test states that have dependencies between states but also test things in parallel that do not have shared states whenever possible.

Describe the solution you'd like A clear and concise description of what you want to happen.

One thought is to support steps tag.

spec-A.ts tagged as step-1 spec-B.ts tagged as step-2 spec-C.ts tagged as step-2 spec-D.ts tagged as step-3 spec-E.ts tagged as step-4 spec-F.ts tagged as step-4 spec-G.ts tagged as step-5

The order of operation would look something like:

spec-A => spec-B + spec-C in parallel => spec-D => spec-E + spec-F in parallel => spec-G

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Another simpler approach might be to support post-parallelizable tags, where it would simply run after the last parallelizable spec.

Additional context Add any other context or screenshots about the feature request here.

Really loving gauge (over cypress) and thanks for taking the time to read/consider this!

hkang1 avatar Dec 02 '20 22:12 hkang1

If for cleanup purposes have you considered using tagged hooks ?

NivedhaSenthil avatar Dec 04 '20 05:12 NivedhaSenthil

If for cleanup purposes have you considered using tagged hooks ?

Hey @NivedhaSenthil,

Ah interesting, I think I get what you are putting down. So if I want to wait for spec-B and spec-C to finish running in parallel then run cleanup. I would tag spec-B near the end scenario with spec-B-completed and the same for spec-C then have a AfterStep(..., [ 'spec-B-completed', 'spec-C-completed' ]);?

hkang1 avatar Dec 04 '20 05:12 hkang1

there is also afterSpec hook which runs after the completion of spec like afterStep which runs after each step

NivedhaSenthil avatar Dec 04 '20 07:12 NivedhaSenthil

awesome thanks @NivedhaSenthil !

hkang1 avatar Dec 04 '20 07:12 hkang1

hey @NivedhaSenthil, so I haven't had much success with AfterSpec with tags. Though I am using gauge-ts, it should still work? So I have enable_multithreading and allow_filtered_parallel_execution set to true. I have the following spec files.

testA.spec

# Test A
Tags: parallelizable, test-a

...

testB.spec

# Test B
Tags: parallelizable, test-b

...

StepsImplemention.ts

export default class StepImplementation {
  @AfterSpec({
    operator: Operator.And,
    tags: ['test-a', 'test-b'],
  })
  public cleanUp() {
    console.log('CLEANING UP');
  }
}

Within the tags array, if I specify either test-a or test-b the console log executes fine after either testA.spec or testB.spec respectively. However when both are included, cleanUp doesn't run at all. Am I doing something wrong?

hkang1 avatar Dec 08 '20 07:12 hkang1

Since you have specified operator as And the hook expects a spec with both tags specified together, you might have to try Or operator if you want the hook to be executor for either of the tags

NivedhaSenthil avatar Dec 11 '20 03:12 NivedhaSenthil

Is there a world where I can get cleanUp to get called after both test-a and test-b have completed during the test? With both test-a and test-b running in parallel.

hkang1 avatar Jan 22 '21 20:01 hkang1

thanks for the response by the way, I just totally missed it back in Dec 10 lol!

hkang1 avatar Jan 22 '21 20:01 hkang1

Not at the moment, test-a and test-b are both tags, and gauge does not track the status of tags, i.e. it does not know when all specs with a specific tag are executed. (not saying this is how it should be though)

sriv avatar Feb 04 '21 11:02 sriv