欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

springboot单元测试

程序员文章站 2022-04-26 09:17:45
...
package com.mb.girl.girlapi.email;

import com.mb.girl.girlapi.email.po.Email;
import com.mb.girl.girlapi.test.po.User;
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.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import javax.annotation.Resource;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.*;

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@SpringBootTest( )
public class SendMailServiceImpTest {

    @Autowired
    private  SendMailServiceImp sendMailServiceImp;

    /**
     * 2018年10月22日22:47:19
     */
    @Test
    public void sendMail() {
        List<Email> ulist = new ArrayList<>();
        Email u = new Email();
        u.setToUSer("[email protected]");
        u.setBodyText("今天吃得好撑");
        u.setObjecttxt("心情好的主题");

        ulist.add(u);

        try {
            sendMailServiceImp.sendMail(ulist);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}