-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properties for test cases #183
Comments
@dennisgrck , fyi, the links for the documentation you provided are not working. |
@bitcoder Thanks a lot for letting me know, I've fixed the links now! |
@michaelleeallen @clayreimann I would be happy to implement this and prepare a PR if you think this would be interesting to review. I would make sure this is a completely tool-agnostic implementation and follows the conventions of other tools that already support this (such as IMO a tool-agnostic way to include test case properties in the resulting XML file will allow many developers to build better integrations with Mocha & various reporting, CI & testing tools that support test case properties already. |
How would that fit exactly a mocha test and a Cypress test for example? |
The proposed API would work exactly like the existing APIs such as |
Well, not totally :) |
@bitcoder This is not the intention of this issue request and not in the scope of what I suggested. My suggestion (and possible PR) is to provide a simple API to specify properties, just like the existing attachment & output APIs. I don't think it's a good idea to extend the function signature for this and this is also not really necessary for my suggestion; any property that can be specified in the function signature can also be specified within the test instead, which works just like the existing APIs. Hope this clarifies it! |
To add some additional information to this request, other popular testing tools such as Pytest and Playwright also support test case properties the same way as the above suggestion, and they also support multiple properties with the same name. Here is an example for Playwright (which uses Playwright's annotations API): test('user profile', async ({ page }) => {
test.info().annotations.push({ type: 'severity', description: 'critical' });
test.info().annotations.push({ type: 'language', description: 'english' });
// Playwright also supports multiple properties with the same name
test.info().annotations.push({ type: 'step', description: 'The first step' });
test.info().annotations.push({ type: 'step', description: 'The second step' });
test.info().annotations.push({ type: 'step', description: 'The third step' });
// [..]
}); And here is the same example for Python & Pytest: def test_function(record_property):
record_property("severity", "critical")
record_property("language", "english")
# Pytest also supports multiple properties with the same name
record_property("step", "The first step")
record_property("step", "The second step")
record_property("step", "The third step")
assert True Instead of using a tool-specific implementation like #153 from one vendor, I would like to suggest using a similar open API for this project. The |
@dennisgrck Sorry for the delay, I'd be happy to review a PR if you were to implement this feature. As long as nothing breaks most any contribution is welcome here |
Sounds good, I will work on this and will try to get the PR ready in the next days. |
Hello there,
I would like to suggest adding support for properties on a test case level. More and more CI and test management tools support this, and this is useful to include & report additional fields and properties for tests (such as test descriptions, test attributes, test steps details etc). This is also supported by various other test frameworks such as
pytest
orPlaywright
, as well as reporting and test management tools such as Testmo.Properties for test cases
Here is an example of what test case properties look like in the resulting XML file. This is the same format as supported for
testsuite
element, just below thetestcase
element:You can also find additional details on this format here as well as a full XML example file.
Possible API suggestion
Similar to how the Mocha JUnit reporter already supports
this.test.consoleOutputs
andthis.test.attachments
, I would suggest adding a new optionalthis.test.properties
field. This could be an array of objects with name/value fields. I would suggest this API as it allows the use of multiple properties with the same name, as this is useful to include e.g. multiple steps, attachments etc. Here's what a possible API could look like:I'm happy to provide more details on how other tools are using these properties. Thanks for considering this feature request!
The text was updated successfully, but these errors were encountered: