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 an 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.