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

Scenario's don't respect Lifecycle functions #3784

Open
ahmednkhan24 opened this issue Jun 7, 2024 · 1 comment
Open

Scenario's don't respect Lifecycle functions #3784

ahmednkhan24 opened this issue Jun 7, 2024 · 1 comment
Assignees

Comments

@ahmednkhan24
Copy link

ahmednkhan24 commented Jun 7, 2024

Brief summary

I have a K6 project with multiple test files.
I'm able to incorporate all of these tests using K6 Scenarios.

I now want to include K6 Lifecycle functions, like setup and teardown for each test.

However, there's no way to specify a setup function in a scenario, similar to how the exec value specifies what function is invoked for the scenario.

If any one test file exports a setup function, that same setup function is used for all tests.

k6 version

v0.50.0

OS

Windows 11

Docker version and image (if applicable)

No response

Steps to reproduce the problem

options.ts

import { Options } from 'k6/options';

const scenarios: Options["scenarios"] = {
  scenario1: {
     exec: 'scenario1FunctionHandler',
     ...
  },
  scenario2: {
     exec: 'scenario2FunctionHandler',
     ...
  }
};

export const options: Options = { scenarios };

test1.ts

export function setup() {
  console.log('test1 setup function');
}

export function scenario1FunctionHandler() {
  ...
}

test2.ts

export function setup() {
  console.log('test2 setup function');
}

export function scenario2FunctionHandler() {
  ...
}

Expected behaviour

The setup for each test respects what it exports.

Actual behaviour

Only 1 setup function is used for all tests

@oleiade
Copy link
Member

oleiade commented Jun 21, 2024

Hi @ahmednkhan24 👋🏻

Thanks a lot for submitting this feature request 🙇🏻

We are aware of this and have it on our radar already. However, it is still being determined whether we will make this possible in the future. We'll make sure to let you know as soon as there is progress on that front 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants