我不能使用Kotlin的Serenity-bdd

我尝试使用kotlin为我的测试与宁静床框架,但是这不起作用例如

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创建步骤库:无法继承最终的类类ru.tinkoff.atesting.steps.serenity.EndUserSteps)

你可以帮我吗? 有什么想法?

在Kotlin类中,默认情况下不允许子类化 (相当于Java的final )。 要允许子类化,您需要将它们标记为open 。 ( open class X

一个类的开放注释与Java的最后一个是相反的:它允许其他人从这个类继承。 默认情况下,Kotlin中的所有类都是final的,这对应于Effective Java,Item 17:设计和文档以进行继承或者禁止它。 – Kotlin文档