JUnit 测试

来源:互联网 发布:天下3用数据流量玩 编辑:程序博客网 时间:2024/06/05 19:04
</pre><pre name="code" class="java">import javax.annotation.Resource;import junit.framework.Assert;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.test.context.ContextConfiguration;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;import com.frm.entity.User;
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations={"classpath:config/applicationContext.xml"})//若多个配置文件,则继续在locations里追加public class DaoSupportTest {@Resource(name="daoSupport")DaoSupport dao;@Testpublic void testFindForObject() throws Exception {User user=(User) dao.findForObject("UserMapper.findUserById", "1");Assert.assertEquals("sj", user.getUsername());}}

0 0
原创粉丝点击