运行为JUnit不会在Eclipse Luna中用于测试单个方法(右键单击该方法)或特定的测试类,只有我才能将整个src / test文件夹作为Junit运行。我在“运行”配置中选择了“运行单一方法”选项。在Java构建路径源文件夹中添加了src / test。甚至检查过重新启动Eclipse都没用。
下面是类(示例目的)
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
public class CommentTableTest<K, V> {
@InjectMocks
CommentTable<K,V> Comment;
@Mock
DAOImpl<Object, Object> dao;
@Mock
Util<Object, Object> Util;
@Mock
ThreadPoolTaskExecutor executor;
@Test
public void testprocess() throws Exception {
MapDetail map = buildMapDetails();
List<Log> list = buildLogListObjects();
List<Log> sublist = buildLogListObjects();
List<Comment> List = buildCommentList();
Mockito.when(dao.getLogRecords(map.getLogQueryForComment())).thenReturn(list);
Mockito.when(Util.getSubList(0, map, list)).thenReturn(sublist);
Mockito.when(dao.selectCommentRecords(sublist, map)).thenReturn(claimList);
Mockito.doNothing().when(dao).updateLogTableStatus(sublist, map);
Comment.processComment(map, executor);
}