[英]what needs to be initialized for spring-boot integration tests to run standalone
這是我的基本測試類的樣子-
@SpringApplicationConfiguration(classes = ServiceApplication.class)
@WebAppConfiguration
@IntegrationTest("server.port:8084")
public class BaseTestStartService {
//TODO:add basic service test
}
不確定在此基類中要實現什么? 正確的程序是什么? 基類在測試類中實現為-
@RunWith(SpringJUnit4ClassRunner.class)
public class TestClass extends BaseTestAPIService{
//add assertions
}
我正在嘗試實施正確的流程,因此需要一些建議。
也許您可以對服務的確切功能和要測試的內容提供更多的見解,例如,使用RestTemplate的REST調用或對組件bean的直接方法調用。
無論哪種方式,一些技巧都可能很有趣:
server.port:0
並最終使用@Value("${local.server.port}")
自動裝配int
@Before
和@After
注釋在基類上設置一組通用的燈具; 無論哪種方式,一種常見的良好做法是保持服務模塊化,並為每個@Test
注釋方法使用一個不同的測試用例。 從您的配置來看,您似乎可以使用大型服務來構建測試。 如果您正在使用“測試驅動開發”並計划稍后隔離測試的服務,那么這可能是一個好習慣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.