javaWeb测试用例

1  普通javaWeb项目
import java.util.List;
import java.util.Map;

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 jd.dao.impl.JdbcDao;
import jd.model.IdentintyTest;
import jd.model.User;
import jd.service.UserService;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:springContext.xml" })
public class CrudTestBase {

	@Autowired
	private UserService userService;
	@Autowired
	private JdbcDao jdbcDao;

	@Test
	public void testGetOne() throws Exception {
		System.out.println(userService.getUser2("ssysd1231"));
		String sql = " select * from t_user where id=?";
		User findByParm = userService.findByParm(User.class, sql, "ssysd1231");
		Map findByParm2 = userService.findByParm(Map.class, sql, "ssysd1231");
		Object findByParm3 = userService.findByParm(Object.class, sql, "ssysd1231");
		System.out.println(jdbcDao);
		System.out.println(userService.getUser2("1f45d9fa254e431ebff6cb755d17266b"));
	}}
2  spring Boot项目
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;

import com.cdjdgm.dip.runtime.RuntimeBox;
import com.cdjdgm.pdms.pxks.service.PdmsPxksExamPlanService;

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@Transactional
@SpringApplicationConfiguration(RuntimeBox.class)
public class CrusTest {
	@Autowired
	PdmsPxksExamPlanService pdmsPxksExamPlanService;
	@Test
	public void testName() throws Exception {
		System.out.println("-----------------------");
		System.out.println(pdmsPxksExamPlanService);
	}
}


你可能感兴趣的:(javaWeb测试用例)