如何解决从 Cucumber 中的 StepDefinition 获取注释
我正在尝试获取注释:("someid") 在自定义插件实现中的黄瓜步骤定义中使用。如何得到这个?有可能吗?
步骤定义
@Group(id="someid")
@Given("today is Sunday")
public void today_is_Sunday() {
today = "Sunday";
}
package hellocucumber.listener;
import io.cucumber.plugin.ConcurrentEventListener;
import io.cucumber.plugin.event.*;
public class StepListener implements ConcurrentEventListener {
@Override
public void setEventPublisher(EventPublisher publisher) {
publisher.registerHandlerFor(TestStepFinished.class,this::handleTestStepFinished);
}
private void handleTestStepFinished(final TestStepFinished event) {
System.out.println("Status: "+event.getResult().getStatus());
System.out.println("Id: "+ event.getTestStep().getId());
System.out.println("Code Location: "+event.getTestStep().getCodeLocation());
if (event.getTestStep() instanceof PickleStepTestStep) {
PickleStepTestStep testStep = (PickleStepTestStep) event.getTestStep();
System.out.println("Get Step:" + testStep.getStep());
testStep.getStep().getText();
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。