目前我使用@BootstrapWith註釋與自定義類一起使用,它只是簡單地設置了一些在測試中使用的系統屬性。但是(據我所知)這些屬性被每個實例TestContextManager來測試和TestContext都會用它時設置:Spring:@BootstrapWith用於ApplicationContext
@BootstrapWith是用於配置 了Spring TestContext框架是怎樣的一類級別註解自舉
有沒有什麼辦法的ApplicationContext開始前一次設置屬性?
編輯:
我不能用@RunWith(SpringJUnit4ClassRunner.class)
由於參數的測試,這需要@RunWith(Parameterized.class)
。我使用SpringClassRule
和SpringMethodRule
而不是
此外,我運行不僅參數化測試,但也運行普通測試。因此,我不能簡單地延長Parameterized
亞軍
你的意思' System.getProperties()'? –
@MaciejDobrowolski啓動ApplicationContext之前的System.setProperty() – Anton
您是否必須全局設置屬性,還是每個測試套件的屬性都不相同? –