junit5-有条件使用扩展
是否可以根据 JUnit5 中的某些条件使用扩展?
我有一个扩展,可以收集测试运行结果并将其发送到外部服务(TestRail)。但我希望为远程运行启用它并为本地运行禁用它。例如这样的:
TestRailListener Implements BeforeAllCallback, TestWatcher
@BeforeAll
public void beforeAll() {
if(!Objects.equals(System.getProperty("runType"), "local")) {
Extension e = new TestRailListener().enable();
}
有什么方法可以实现它吗?
Is it possible to use extension depending on some condition in JUnit5?
I have extension that collect and send test run results to external service (TestRail). But I want to have it enabled for remote runs and disabled for local runs. E.g. something like this:
TestRailListener implements BeforeAllCallback, TestWatcher
@BeforeAll
public void beforeAll() {
if(!Objects.equals(System.getProperty("runType"), "local")) {
Extension e = new TestRailListener().enable();
}
Is there any way to achieve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JUnit Jupiter 提供程序化扩展注册。
因此,您可以在运行时使用附加参数配置扩展。
JUnit Jupiter provides Programmatic Extension Registration.
So you can configure you extensions with additional parameters at runtime.