Spring Boot单元测试

代码示例

XxxServer是启动类,注释有:@SpringBootApplication
import com.xx.service.xx.FacadeService;
import org.junit.Test;
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;

@RunWith(SpringRunner.class)
@SpringBootTest(classes={XxxServer.class})
public class JunitTest {

    @Autowired
    private FacadeService facadeService;

    @Test
    public void testA() {
        facadeService.deal(1);
    }
}

 

你可能感兴趣的:(Spring,Boot)