首页 > 其他分享 >建立一个Springboot的测试环境

建立一个Springboot的测试环境

时间:2022-11-30 07:55:05浏览次数:34  
标签:Springboot 建立 Application org test import TestApp class 测试环境

/**
 * Created by test on 2022/09/3 10:29
 */
 
import com.jeesite.modules.Application;
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;
 
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)//该class是SpringBoot项目的Application
//@ActiveProfiles("test")
@WebAppConfiguration
/*@TestPropertySource({//引用的配置文件
        "classpath:/config.properties"
})*/
public abstract  class TestApp {
}

具体测试类可以extends这个TestApp:

 import org.junit.Test;
 
import javax.annotation.Resource;
 
/**
 * Created by test on 2022/09/3 10:30
 */
public class TestTjStock extends TestApp {
  @Resource
  private TjStockDao tjStockDao;
  @Test
  public void testRemoveAll(){
    tjStockDao.removeAll();
  }
}

标签:Springboot,建立,Application,org,test,import,TestApp,class,测试环境
From: https://www.cnblogs.com/zq777/p/16937326.html

相关文章