这些注释与任何基于Java的测试框架以相同的方式使用.
要创建一个步骤:
一个例子:
@Test
public void someTest() throws Exception {
//Some code...
stepLogic();
//Some more assertions...
}
@Step("This is step 1")
private void step1Logic() {
// Step1 implementation
}
@Step("This is step 2")
private void step2Logic() {
// Step2 implementation
}
Run Code Online (Sandbox Code Playgroud)
要创建附件:
例:
@Test
public void someTest() throws Exception {
//Some code...
createAttachment();
//Some more assertions...
}
@Attachment(name = "My cool attachment")
private byte[] createAttachment() {
String content = "attachmentContent";
return content.getBytes();
}
Run Code Online (Sandbox Code Playgroud)
为了使@Step和@Attachment注释工作,您需要在配置中正确启用AspectJ.这通常通过指向aspectj-weaver.jar文件的-javaagent JVM参数来完成.
进一步阅读: