zoukankan      html  css  js  c++  java
  • springmvc,springboot单元测试配置

    1. springmvc单元测试配置

    <dependency>
    	<groupId>junit</groupId>
    	<artifactId>junit</artifactId>
    	<version>${junit.version}</version>
    	<scope>test</scope>
    </dependency>
    
    package com.test;
    
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import lombok.extern.slf4j.Slf4j;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.test.context.ContextConfiguration;
    import org.springframework.test.context.junit4.SpringRunner;
    
    
    
    @Slf4j
    @RunWith(SpringRunner.class)
    @ContextConfiguration(locations = {"classpath:applicationContext_.xml"})
    public class ImageTask {
        @Autowired
        ItemService itemService;
    
        @Test
        public void request() {}
    }
    

    2. springboot单元测试配置

    <dependency>
    	<groupId>org.springframework.boot</groupId>
    	<artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    
    package com.test;
    
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.amqp.core.AmqpTemplate;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.test.context.junit4.SpringRunner;
    
    import java.util.HashMap;
    import java.util.Map;
    
    @RunWith(SpringRunner.class)
    @SpringBootTest
    public class SmsTest {
    
        @Autowired
        private AmqpTemplate amqpTemplate;
    
        @Test
        public void testSend() throws Exception{}
    }
    
  • 相关阅读:
    DOS批量递归删除文件夹
    根据关键词kill进程
    docker创建镜像的几个命令
    OpenSSL命令---passwd
    A configuration with this name already exists
    查看Linux版本
    ubuntu初次安装后设置root用户密码
    [转载]气象数据集下载网站(包括中国700多个站)
    将界面从屏幕外拖回来方法
    使用GitHub分享代码
  • 原文地址:https://www.cnblogs.com/Lothlorien/p/11909706.html
Copyright © 2011-2022 走看看