Testcafe: Add "group" metadata to define which tests will be run

Created on 19 Jun 2018  路  5Comments  路  Source: DevExpress/testcafe

Are you requesting a feature or reporting a bug?

A feature, posted by one of TestCafe customers (see details below)

In one of the recent releases I noticed that test and fixture metadata can now be added to the test scripts. Would it be possible in the future to use the metadata of a test to group them when running from command line? ie setting test.meta({sanity: true, fullRegression: true, feature1: false}) then from command line start all tests that have --meta '{sanity: true}' when i want to run only a small subset of my scripts?

I'm currently doing this using globs on Fixture and Test names but they will become long and involved with too many unsafe keywords when I expand my test suite.

Specify your

  • testcafe version: 0.20
Auto-locked enhancement

Most helpful comment

This is a much needed feature. Ability to run a particular category of tests using their meta data set on the test or the fixture.
Example: test.meta({smoke: true, feature: true}) or fixture.meta({crud: read})
Command to run only smoke tests : testcafe --meta "smoke:true" test
Command to run only read tests : testcafe --meta "crud:read" test
or something similar.

Testcafe version : 0.21.1

All 5 comments

This is a much needed feature. Ability to run a particular category of tests using their meta data set on the test or the fixture.
Example: test.meta({smoke: true, feature: true}) or fixture.meta({crud: read})
Command to run only smoke tests : testcafe --meta "smoke:true" test
Command to run only read tests : testcafe --meta "crud:read" test
or something similar.

Testcafe version : 0.21.1

I've implemented this feature in this PR.

The --meta JSON (eg: --meta {smoke: true}) flag was introduced. Only tests whose metadata matches the provided json will be run.

Is there any way to use the filter when a test omits the meta tag. ie
if we execute test with --test-meta smoke=false
and only have some tests marked up with test.meta("smoke","true")
it would be useful to have all tests without the attribute to execute the test given they do not meet truthy.

@jafin As the docs state: metadata value's are strings, so it really doesn't have sense to speak of _truthy_ or _falsy_ value. If you read the PR's comments, you will fully understand the cmd line api decision.

Anyway, you can implement you own custom runner, using the programming interface, to have the custom behavior that you need.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.

Was this page helpful?
0 / 5 - 0 ratings