import javax.annotation.Resource;
import org.junit.Assert;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring/ApplicationContext-dao.xml")
public class JunitTest extends AbstractJUnit4SpringContextTests {
@Resource(name = "handler")
private handler handler;
private int id;
private int userId;
@Before
public void init(){
id=599;
userId = 368469;
}
@After
public void destroy(){
}
@Test
public void test() {
Assert.assertNotNull(this.handler);
try {
System.out.println(handler.queryAddressById(id, userId));
} catch (Exception e) {
System.out.println(e);
}
}
}
spring的单元测试
最新推荐文章于 2024-05-27 23:03:55 发布