在我的跑步者 class 中提供标签作为黄瓜选项时出现 'java.lang.String' 错误的非法初始值设定项

Illegal initializer for 'java.lang.String' error while supplying tags as cucumber options in my runner class

我遇到编译错误 - 在我的运行器 class 中提供标签作为黄瓜选项时 'java.lang.String' 的初始值设定项非法。这曾经在 info.cukes 上运行良好,但在升级到 io.cucumber.

后不起作用

这是我的跑步者class-

import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;

@CucumberOptions(
        features = "target/test-classes",
        monochrome = true,
        plugin ={"json:target/cucumber-report.json", "html:target/cucumber-reports.html"},
        tags = {"@Smoke", "@Sanity","@Reg"} )

public abstract class BaseRunner extends AbstractTestNGCucumberTests {
}

附上相同的下方-

替换为 tags="@Smoke or @Sanity or @Reg"tags="@Smoke and @Sanity and @Reg",随你喜欢。

在 io.cucumber 中,标签应不带“{}” 于是就变成了,

@CucumberOptions(
    features = "target/test-classes",
    monochrome = true,
    plugin ={"json:target/cucumber-report.json", "html:target/cucumber-reports.html"},
    tags = "@Smoke", "@Sanity","@Reg" )

它应该可以工作。