zoukankan      html  css  js  c++  java
  • springboot项目

    引入:

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    

    选中要测试的类, Alt + Enter 出现 create Test, 选中junit4
    要在有启动类的项目中创建
    注意这两个注解:
    @SpringBootTest 或者 @SpringBootTest(classes = 当前启动类名.class)
    @RunWith(SpringRunner.class)


    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;
    import static org.junit.Assert.*;
    
    @SpringBootTest(classes = WebApplication.class)
    @RunWith(SpringRunner.class)
    public class DocumentPoliciesReleaseControllerTest {
    
        @Autowired
        private DocumentPoliciesReleaseService service;
    
        @Test
        public void delete() {
            System.out.println("service = " + service);
        }
    }
    
  • 相关阅读:
    对协程的一些理解
    JUC中Lock和ReentrantLock介绍及源码解析
    JUC中AQS简介
    Executor框架简介
    CyclicBarrier简介
    CountDownLatch简介
    Semaphore简介
    ThreadPoolExecutor简介
    AtomicInteger简介
    synchronized和volatile简介
  • 原文地址:https://www.cnblogs.com/wqkeep/p/13202651.html
Copyright © 2011-2022 走看看