依赖:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
1.在src下新建test路径,右击选择marker directory as -》选择 Test resources root文件夹变为绿色
2.右击需要单元测试的方法-》Go to -》test-》create(第一次)
3.写测试类:
package com.Orz.service.serviceImpl;
import com.Orz.domain.User;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.cl