123456789101112131415161718192021222324252627282930313233343536373839 |
- package com.gxzc.zen.base
- import org.junit.Before
- import org.junit.runner.RunWith
- import org.springframework.beans.factory.annotation.Autowired
- import org.springframework.boot.test.context.SpringBootTest
- import org.springframework.test.context.junit4.SpringRunner
- import org.springframework.test.context.web.WebAppConfiguration
- import org.springframework.test.web.servlet.MockMvc
- import org.springframework.test.web.servlet.setup.MockMvcBuilders
- import org.springframework.web.context.WebApplicationContext
- /**
- * Spring单元测试基类
- * @author NorthLan
- * @date 2018/1/26
- * @url https://noahlan.com
- */
- @RunWith(SpringRunner::class)
- @SpringBootTest
- @WebAppConfiguration
- //@Transactional // 事物支持
- class BaseTestKt {
- @Autowired
- lateinit var webApplicationContext: WebApplicationContext
- lateinit var mockMvc: MockMvc
- @Before
- fun setupMockMvc() {
- mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build()
- }
- @Before
- fun initDataBase() {
- // Nothing
- }
- }
|