春のブートに成功し正常に起動しましたが、テストオブジェクトが、その場合、どのようにそれを行うには、すべての空の中に注入されますか?
TestNGのを使用して、元のメソッドは、クラスを開始し、直接の容器内のブートオブジェクトを春に使用することはできません、手動で拾うことが必要である、唯一の数行のコードを追加する必要が正常に使用することができます
パブリック静的のApplicationContextのApplicationContext。
パブリック静的PreProfitTestCase preProfitTestCase。
パブリック静的PreProfitUrl preProfitUrl。
@BeforeClass
ます。public voidスタート(){
場合(Application.started!){
のApplicationContext = SpringApplication.run(Application.class)。
Application.started =はtrue。
} {他
のApplicationContext = Application.get()。
}
preProfitUrl = applicationContext.getBean(PreProfitUrl.class)。
preProfitTestCase = applicationContext.getBean(PreProfitTestCase.class)。
}