spring boot 单元测试

import com.alibaba.dubbo.config.annotation.Reference;
import com.xxx.Application;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * 测试
 * @author bozi
 *
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes=Application.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)// 指定启动类
//@SpringBootTest(classes = {Application.class})// 指定启动类
//@EnableAutoConfiguration
public class DemoTest {

	@Autowired
	private TestService testService;
	
	@Reference
	private TestApiService testApiService;

	
	@Test
	public void testMythed() throws Exception {
		System.out.println("11111111111111");
	}
}

 

你可能感兴趣的:(spring,boot)