簡體   English   中英

集成測試中注入服務的問題

[英]Problems injecting services in integration test

我有一個類似的問題,就是使用此代碼通過注入對Grails服務進行集成測試

@TestFor(DocumentosService)
class DocumentosServiceTest extends GroovyTestCase  {
    def myService
    void testEnvioEmailDocumento() {
        assert myService != null
    }
}

執行測試時,myService始終為null。 為什么未注入myService? 我正在使用Grails 2.1

根據Burt Beckwith的指示進行了更新(2013/2/6):

class DocumentosServiceTest extends GroovyTestCase  {
    def myService
    def documentosService
    void testEnvioEmailDocumento() {
        assert documentosService != null
        assert myService != null
    }
}

現在documentosService也為null。

刪除@TestFor(DocumentosService)因為它用於單元測試。 為服務添加常規的依賴項注入,在這種情況下,它看起來像是def documentosService

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM