-
-
Notifications
You must be signed in to change notification settings - Fork 513
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
Factorization Serenity response in validator class and fluent annotation #1863
Comments
You can use SerenityRest.lastResponse(). But I would just use a custom-made class that takes a ValidatableResponse object in the constructor and use soft asserts. The "fluent" attribute is not currently active. |
Hi, I am with @krys86 on that issue. The point is that we already use the ValidatableResponse. The Our issue is to have a fluent design but which preserves the steps definitions, to make them appear in the report. The ValidatableResponse does not do that, so we put it in our custom method on which a Our question is how to redesign our custom methods in a fluent manner without loosing them in the report? |
Have you considered a builder pattern that uses a fluent interface to prepare the API call, and then makes the call with a @step method at the end? That’s how it works with Screenplay. |
If we use a single builder instance, we lack in code correctness: one can call the end method without calling the 'onResponse(...)'. Moreover, it becomes interesting for a SOLID design bexause we can have a single Validator, from which we can obtain a ResponseValidator with 'onResponse(response)', an EnvironmentValidatoe with 'onEnv()', which allows us to create different classes for different types of validations. But this design requires to generate a ResponseValidator instance on the fly, but still consider it as a source of Steps to retrieve in the report. So far we were unable to keep them in the report with the new instance. |
That will be hard to do using step library class. |
But this is the goal. We use Serenity since only recently, so we are far from mastering it, so maybe you can pinpoint us on some wrong ways we are going. So far, we are forced to use a The other limitation is that we must keep the Is there some other ways to go which could help us adapt the design of our classes without losing the reporting? |
If you use the Screenplay pattern you will have more flexibility about how you create your classes and methods. |
I read a post about how to use the Screenplay of Serenity in Java: Honestly, I am not convinced about it at all. I find it far too heavy given our simple case. However, it gave me the right hints with the instrumented classes. More precisely, I import your Instrumented class:
It allows me to instrument my instance, although I need to feed it after instanciation but that's OK:
This way, I can have a fluent design:
I can then reuse that in a more global Validator class or whatever without needing We will experiment on that. Thank you. |
Hello
To perform validation check on the response of our API, we created the various steps we need:
The problem is we are obliged to pass the
response
in the method every time, which makes the code heavy and forces us to rewrite each step description to remove it.Would it be possible to pass the response to the validator and perform the check without passing it to every method?
We have in mind something like this:
This way the response is provided once and the steps description can build on the method name and arguments.
Moreover, checking the documentation, I saw there is a "fluent" attribute for the "Step" annotation but there is no doc at all about its meaning. Could it help?
Thanks in advance
The text was updated successfully, but these errors were encountered: