Hi,

the recommended way is to inject a context object in your steps classes via 
which you can share your events from one steps class to another.

If this is not what you meant please provide a sample project to illustrate 
your use case.

Thanks

> On 31 Jul 2017, at 09:45, SpeedMax Alice <[email protected]> wrote:
> 
> Hey, 
> 
>      Right now I need to log some runtime info like api response body, 
> selenium log in steps and bind it to the actual performed steps
>      I've check all the possible way I can but got nothing.
>      Anybody can give me a hint?
> 
>      My solution right now is ugly and only works when steps throw 
> exception(commonly exception create by Assert Library).
>      
> @Then("search '$item' on Ebay with quotes")
> public void searchItemOnEbayWithQuotes(@Named("item")String item) throws 
> Exception {
>    s(log -> {
>       new HomePage().search(item);
>       log.info("SEARCH ITEM " + item + " ON EBAY SITE.");
>       log.info("SEARCH ITEM " + item + " ON EBAY SITE.");
>       log.info("SEARCH ITEM " + item + " ON EBAY SITE.");
>       log.info("SEARCH ITEM " + item + " ON EBAY SITE.");
>       throw new Exception("test exception");
>    });
> }
> 
> void s(stepCallable callable) throws Exception {
>    LOGGER logger = LOGGER.newLOGGER();
>    try {
>       callable.apply(logger);
>    } catch (Exception e ) {
>       throw new Exception("\n\t" + logger.toString());
>    }
> }
> 
> @FunctionalInterface
> public interface stepCallable {
>    void apply(LOGGER logger) throws Exception;
> }
> 
> In the demo you can see:
> a callable called stepCallable
> a step wrapper function called s to wrap step code into lambda and rebuild a 
> new exception with customized log and throw it out
> finally the log will be stored into steps's UUIDExceptionWrapper 
> 
> this is the only way I found to keep runtime info into performed steps.
> 
> 
> If anyone have a better way to do similar thing, just comment down blow.
> Actually I need runtime info inside steps, not after or before hook.
> thanks!
> 
>      
> -- 
> You received this message because you are subscribed to the Google Groups 
> "JBehave Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web, visit 
> https://groups.google.com/d/msgid/jbehave-dev/bc862b22-9d37-470a-8012-c3e9ec641ace%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"JBehave Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send an email to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/jbehave-dev/AB8FDE07-A83D-4AA8-B57A-1B39D5ED1B9C%40aquilonia.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to