我正在尝试各种方法,使用量角器在诱惑报告插件中嵌入测试运行视频。如果我们在诱惑报告文件夹中添加一个视频文件夹并在诱惑描述中添加视频路径,我们可以做到。因此,Allure在描述部分显示并播放视频。
但是,我想使用 Allure Jenkins 插件实现相同的目标。您能否让我知道是否有任何方法可以在使用 allure jenkins 插件生成的诱惑报告中嵌入和播放视频。
我看到了你管上的视频,他们在詹金斯的诱惑报告中运行视频。但不确定他们是如何设置的。请帮忙?https://www.youtube.com/watch?v=74zD5q9DKTw
似乎没有"Jenkins插件"的业务,你可以重写testngListener,并添加带有"Attachement"的vedios。
@Override
public void onTestFailure(ITestResult result) {
super.onTestFailure(result);
String mp4 = store + "\" + sessionId + ".mp4";
File file = new File(mp4);
if (file.exists()) {
attachRecord(mp4);
}
}
@Attachment(value = "record screen", type = "video/mp4")
private byte[] attachRecord(String mp4) {
System.out.println("mp4 -->" + mp4);
Path content = Paths.get(mp4);
InputStream is = null;
try {
is = Files.newInputStream(content);
} catch (IOException e) {
e.printStackTrace();
}
return is2ByeteArray(is);
}
public static byte[] is2ByeteArray(InputStream is) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buff = new byte[100];
int rc = 0;
while (true) {
try {
if (!((rc = is.read(buff, 0, 100)) > 0)) break;
} catch (IOException e) {
e.printStackTrace();
}
baos.write(buff, 0, rc);
}
return baos.toByteArray();
}