我不能将 Kotlin 用于 Serenity-bdd

I can't use Kotlin for Serenity-bdd

我尝试将 kotlin 用于 serenity-bed 框架的测试,但这不起作用 例如

public class EndUserSteps {

    var dictionaryPage: DictionaryPage = null!!

    @Step
    fun enters(keyword: String) {
        dictionaryPage.enter_keywords(keyword)
    }

    @Step
    fun starts_search() {
        dictionaryPage.lookup_terms()
    }

    @Step
    fun should_see_definition(definition: String) {
        assertThat(dictionaryPage.definitions, hasItem(containsString(definition)))
    }

    @Step
    fun is_the_home_page() {
        dictionaryPage.open()
    }

    @Step
    fun looks_for(term: String) {
        enters(term)
        starts_search()
    }
}

其他代码已写在Java!

输出: (net.serenitybdd.core.exceptions.StepInitialisationException: 未能为 EndUserSteps:Cannot subclass final class class ru.tinkoff.atesting.steps.serenity.EndUserSteps 创建步骤库)

你能帮帮我吗? 有什么想法吗?

在 Kotlin 类 don't allow subclassing by default 中(相当于 Java 的 final)。要允许子类化,您需要将它们标记为 open。 (open class X)

The open annotation on a class is the opposite of Java's final: it allows others to inherit from this class. By default, all classes in Kotlin are final, which corresponds to Effective Java, Item 17: Design and document for inheritance or else prohibit it. -- Kotlin docs