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

Skip method parameters in report if description of step provided #469

Closed
a-en opened this issue Jun 30, 2016 · 5 comments
Closed

Skip method parameters in report if description of step provided #469

a-en opened this issue Jun 30, 2016 · 5 comments

Comments

@a-en
Copy link
Contributor

a-en commented Jun 30, 2016

Hi there!
Due to some specifics, toString() method of the parameter, that I pass to step is huge & non-readable. I thought that the one of the solution would be something like

`
@step("Perform step1")
public void step1(Object someObj) {
step2(object.getName());
}

@step
public void step2(String name) {
//do something with name
}
`

So in the report I expected to see:

  • Perform step1
    • Step 2: John

I wanted to completely replace the output from step1 in the report by providing explicit description without '{}' and avoid invoke toString() on someObj. This step1() should call step2(), which would produce much prettier output. But now I still get output of someObj's toString(). Is it somehow possible to handle this?

@Invictum
Copy link

@a-en
You may redefine toString of your object if this acceptable. In this case normal data will be displayed in report.

@a-en
Copy link
Contributor Author

a-en commented Jun 30, 2016

@Invictum
Unfortunately it is not possible.

@YamStranger
Copy link
Member

Hello @a-en

Unfortunately now such behaving is not implemented, so you should redefine toString method to do what you need.

As for me such functionality can be implemented in future, some object can be passed as parameter to Step annotation to make it possible provide custom toString convention rules (as @qualifier for parameterized tests)

May be if you can not redefine toString method you can create some wrapper for it, and redefine only toString method - and delegate others?

@a-en
Copy link
Contributor Author

a-en commented Jul 1, 2016

Hi Yam!
Thanks for proposal, I was considering this option as well. Couple of thins preventing me from moving in that direction: amount of the wrappers that should be created and quantify of fields in these objects. I mean, it would be complicated to create universal toString() because based on the context some fields might be needed(initialized) or not.

So, I believe there are a couple of possible ways to add more flexibility to @step annotation:

  • add some method like boolean skipParameters(), so as result something like @Step(skipParameters = true) would result to skipping toString() calls for passed params;
  • pass object which contains custom rules for processing passed parameters to report.

@YamStranger
Copy link
Member

@a-en thanks for your ideas!!!

@wakaleo wakaleo closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants