question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Define steps manually

See original GitHub issue

I’m submitting a …

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

Having code like this

@Test
@Step("TRegister")
public void test()
{
    step("Goto homepage");
    //code

    step("Assure not logged in status");
    //code

    ...
}

@Step("\"{stepName}\" step")
public void step(String stepName)
{
}

This yields in a report that looks like that: chrome_2017-11-16_18-10-44

What is the expected behavior?

But I want to have it to look like that: https://ci.qameta.io/job/allure2/job/master/Demo_Report/index.html#suites/fd187460706bbe14b8a84cc98c3fb991/1063eec919e2a469/ chrome_2017-11-16_18-26-11

The icons indicate a passed/fail behaviour and timing seem to be correct.

What is the motivation / use case for changing the behavior?

If I would split my test case in many functions and annotate them correctly I would get that but the test case wouldn’t be readable anymore. I work on top of an high level api that reduces the code needed for testing to a few lines. So I would have to wrap (in average) less then 3 lines in a function. So it would be nice to define step during runtime so we could achieve the same behaviour as if it would be in annotatd functions.

Please tell us about your environment:

Allure version 2.4.1
Test framework JUnit@4.12
Allure adaptor allure-junit@2.0-BETA19
Generate report using allure-maven@2.9

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
baevcommented, Dec 7, 2017

you can use AllureLifecycle:


    public interface StepBody {
        void execute() throws Exception;
    }
    
    ...
    public static void step(final String name, final StepBody body)
        final String uuid = UUID.randomUUID().toString();
        final StepResult result = new StepResult()
                .withName(name);
        getLifecycle().startStep(uuid, result);
        try {
            body.execute();
            getLifecycle().updateStep(uuid, s -> s.withStatus(Status.PASSED));
        } catch (Exception e) {
            getLifecycle().updateStep(uuid, s -> s
                    .withStatus(getStatus(e).orElse(Status.BROKEN))
                    .withStatusDetails(getStatusDetails(e).orElse(null)));
            throw e;
        } finally {
            getLifecycle().stopStep(uuid);
        }
    }
2reactions
baranoff-ivancommented, Nov 30, 2017

With Java 8 you could do something like that:

@Test
@Step("TRegister")
public void test()
{
    step("Goto homepage", () -> {
        //code
    });


    step("Assure not logged in status", () -> {
        //code
    });

    ...
}

@Step("\"{stepName}\" step")
public void step(String stepName, Runnable actions) {
   actions.run();
}

And that is your variant of implementation? How do you suppose to wrap actions in step mannually? Like below?

@Test
@Step("TRegister")
public void test()
{
    startStep("Goto homepage");
        //code
    stopStep("Goto homepage");

    startStep("Assure not logged in status");
        //code
    stopStep("Assure not logged in status");

    ...
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Process Manual Definition | Law Insider
Project Manual means the volume usually assembled for the Work which may include the bidding requirements, sample forms, and other Contract Documents.
Read more >
Manually Definition & Meaning | Dictionary.com
using or requiring human effort, input, skill, power, etc.:Data extraction was originally done manually, requiring significant resources to complete the tedious ...
Read more >
Manual Definition & Meaning - Merriam-Webster
The meaning of MANUAL is of, relating to, or involving the hands. How to use manual in a sentence.
Read more >
Manual Process vs Automated Process: A Comparison Guide
A manual process is more time-consuming and expensive than an automated process. Manual processes involve one or more humans performing tasks, ...
Read more >
Policy and Procedure Manual: What is it & How to Create it?
How to Create a Policies and Procedure Manual? Follow these Steps! · Step 1: Add Title · Step 2: Write the description ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found