企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ package com.test.test; import com.test.dao.CustomerDao; import com.test.domain.Customer; 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 java.util.List; @RunWith(SpringJUnit4ClassRunner.class) // 扫描spring提供的单元测试环境 @ContextConfiguration(locations = "classpath:applicationContext.xml") // 指定spring容器配置信息 public class TestCustomer { @Autowired private CustomerDao customerDao; @Test public void testFind(){ List<Customer> all = customerDao.findAll(); for (Customer c : all){ System.out.println(c.toString()); } } @Test public void testSave(){ Customer customer = new Customer(); customer.setName("aaaaa"); customerDao.save(customer); } @Test public void testDel(){ customerDao.deleteById(2L); } } ~~~