首页 > 解决方案 > 黄瓜定制插件

问题描述

如何在测试运行器中指定定制的黄瓜插件?

我收到以下错误

java.lang.IllegalArgumentException: The plugin specification 'UD.Plugin' has a problem:

Could not load plugin class 'UD.Plugin'.

Plugin specifications should have the format of PLUGIN[:[PATH|[URI [OPTIONS]]]

预期的格式是什么,

如果我的插件位于 Src/main/UD 并且运行器位于 Src/Test/TestRunner

注意:我用的是黄瓜 4

标签: javaseleniumcucumber

解决方案


提到

cucumber.plugin = com.test.support.ReportPlugin

junit-platform.properties

我的插件文件在src/test/java/com.test.support并且属性文件在 src/test/resources/junit-platform.properties

我相关的 pom 配置是

  <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.7.0</version>
            <scope>test</scope>
      </dependency>
      
    <dependency>
      <groupId>io.cucumber</groupId>
      <artifactId>cucumber-java</artifactId>
      <version>6.9.1</version>
      <scope>test</scope>
    </dependency>

插件文件看起来像这样

package com.test.support;


import io.cucumber.plugin.EventListener;
import io.cucumber.plugin.event.*;

import java.net.URI;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;

public class    ReportPlugin implements EventListener {

....
....

推荐阅读