Skip to content
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

historyId does not take dynamic allure parameters into account #1230

Closed
ToBey1106 opened this issue Jan 24, 2025 · 5 comments · Fixed by #1236
Closed

historyId does not take dynamic allure parameters into account #1230

ToBey1106 opened this issue Jan 24, 2025 · 5 comments · Fixed by #1236

Comments

@ToBey1106
Copy link

Describe the bug
When executing the same test several times and adding a dynamic parameter, the allure report just shows one test result. The same issue was already reported for allure-python.

To Reproduce
Steps to reproduce the behavior:
Run a cucumberjs test multiple time and add a dynamic parameter to create multiple result files:

import { Then } from "@cucumber/cucumber";
import * as allure from "allure-js-commons";

Then("do something", async () => {
  await allure.paramter('randomNumber',Math.random()); 
});

Expected behavior
There should be one test case per run.

Desktop (please complete the following information):

  • OS: Windows 10
  • Chrome 131
  • allure-cucumberjs 3.0.9
@baev
Copy link
Member

baev commented Jan 24, 2025

You need to mark the parameter as excluded. See https://allurereport.org/docs/how-it-works-test-result-file/#parameters-array for details:

Then("do something", async () => {
  await allure.parameter('randomNumber', Math.random(), { excluded: true }); 
});

@ToBey1106
Copy link
Author

I tried your proposal, but it seems you got me wrong.

My expectation is, that when running the same test several times and just a parameter changing, allure creates different entries.

Image

But currently I only see one of the entries, even with your suggestion.

When adding e.g. the version hash to the historyId, I get the above result, as expected.

@baev
Copy link
Member

baev commented Jan 29, 2025

I tried to reproduce the problem. However, I had no luck:

As you suggested, I added the dynamic parameter:

import { Given } from "@cucumber/cucumber";
import { parameter } from "allure-js-commons";

Given("sample step", async function () {
  await parameter('randomNumber',String(Math.random()));
});

when I run tests two times:

$ npm test
$ npm test

then, the report shows two different results as expected

Image

if I exclude the dynamic parameter

import { Given } from "@cucumber/cucumber";
import { parameter } from "allure-js-commons";

Given("sample step", async function () {
  await parameter('randomNumber',String(Math.random()), { excluded: true });
});

then only the last result is shown:

Image

It looks to me like everything works as expected. The example I used: https://github.com/allure-examples/cucumberjs-npm-cjs-ts.

@ToBey1106
Copy link
Author

ToBey1106 commented Jan 29, 2025

When taking a look at your response, I had an idea:
We are adding the parameter in the Before hook.
I tried it locally: If I add a random parameter in the Given step, everything works properly. If I add the random parameter in the Before hook, I get the above described behavior.

Sorry for the wrong example above - I thought this is a general problem.

Can you reproduce it, when adding the parameter in the hook?

@baev
Copy link
Member

baev commented Jan 29, 2025

Yes, according to the code, we set the historyId before we process parameters from hooks.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants