Luxe-Quality / docusaurus_issues

Rise an issue if you found any bug in the knowledge base
0 stars 0 forks source link

WDIO - Materials - Divide a test into steps in Allure report #19

Closed OleksandrBaior closed 3 months ago

OleksandrBaior commented 4 months ago

To create steps and sub-steps, you can use the step() function, see the reference.

const { allure } = require("allure-mocha/runtime");

it("steps", () => {
  allure.step("Step 1", () => {
    allure.step("Sub-step 1", () => {
      // ...
    });
    allure.step("Sub-step 2", () => {
      // ...
    });
  });
  allure.step("Step 2", () => {
    // ...
  });
});

Test steps

Test steps are a mechanism for structured logging, supported by most Allure adapters.

A step begins and ends around a block of code, typically a function or a lambda function, with the step name describing what the code is trying to do: “Initializing test data,” “Connecting to the server,” etc. Unlike a simple text log entry that can only show you a single event, a step allows you to view the execution results of the entire code block. A step may also contain nested steps forming a tree-like structure.

In the test report, Allure displays steps in chronological order, preserving the nesting structure. For each step, it shows its separate duration, status, and, optionally, parameters and attached files.

chrome_qNyfEwt349

Why use test steps? Using steps in your test serves two purposes: to simplify test debugging and to improve test documentation.

Simplify debugging of your tests Just like any other form of logging, steps help you see which sections of the test code were executed and which were not. But unlike a traditional log entry, each step is an interval, not an instant. That fact helps you find the code block that has started but hasn't finished successfully, judging by the steps' statuses. This is also useful when looking for code blocks that take too long to run, thanks to the duration being shown next to each step.

Once you've identified a troublesome code block, Allure will help you further investigate what happened by providing a comprehensive error message with the stack trace.

The report can be improved even further by adding attachment to the steps. One common practice is to log the state of a graphical user interface by attaching a screenshot on each step. For complex test scenarios, this will help understand where exactly something went wrong, without resorting to manual testing.

For most languages and test frameworks, Allure provides a way to set special annotations (attributes, decorators) to your test functions, thus automatically turning each call of the functions into a step or sub-step with minimal effort.

zefirlover commented 3 months ago

Стандартні налаштування are just fine та годяться для практично всіх ситуацій, тому поки жодного оновлення інформації про allure не передбачається