2017-06-18 52 views
1

我嘗試用科特林我安詳牀框架的測試,但是這並不例如我不能使用科特林的寧靜,BDD

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步庫:不能繼承final類類ru.tinkoff.atesting.steps.serenity.EndUserSteps)

你能幫助我? 有什麼想法嗎?

回答

3

在Kotlin類don't allow subclassing by default(相當於Java的final)。要允許子類化,您需要將它們標記爲open。 (open class X

類的開放註釋與Java的最後一個相反:它允許其他人從這個類繼承。默認情況下,Kotlin中的所有類都是final的,它對應於Effective Java,Item 17:設計和用於繼承的文檔,或者禁止它。 - Kotlin docs

+0

你是對的! Modifier *打開*課前,真正解決了啓動問題 – Alex