1. 程式人生 > >springboot單元測試

springboot單元測試

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(); } } }