Spring boot 单元测试

import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.junit.Test;

import com.lgsc.cjbd.BookApplication;

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@SpringBootTest(classes = BookApplication.class, webEnvironment = SpringBootTest.WebEnvironment.MOCK)
public class MyTest {
	
	@Test
	public void testGreen(){
		
	}
}


注意:类名千万别取 Test ,别问我为什么 T_T -> 狗血错误


你可能感兴趣的:(Spring boot 单元测试)