测试restcontroller接口的main方法怎么写
发布网友
发布时间:2022-04-29 09:34
我来回答
共1个回答
热心网友
时间:2022-06-10 14:38
web项目一般有单元测试对模块进行测试,下面是个springmvc单元测试的实例,更多的请自己百度“单元测试”。
package com.xxxx.isms.controller;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:config/spring-*.xml" })
public class CommonControllerTest extends AbstractTransactionalJUnit4SpringContextTests {
@Autowired
private CommonController commonController;
@Test
public void testReloadBMTableData2() {
Assert.assertEquals("reload成功", commonController.reloadBMTableData("IDC_JCDM_GJCDJ", ""));
}
}