断言测试false是什么情况啊????
是不是你的<property name="hbm2ddl.auto">create</property>这条属性导致你输入进去的用户数据被删除?
public class TestLogin { @Test public void TestUsersLogin(){ Users users = new Users(1, "小刚", "19961216"); UsersDao dao = new UsersDaoImpl(); Assert.assertEquals(true, dao.usersLogin(users)); } /** * 添加学生测试 */ @Test public void TestsaveStudent(){ Configuration configuration = new Configuration().configure(); ServiceRegistry registry = new ServiceRegistryBuilder() .applySettings(configuration.getProperties()).buildServiceRegistry(); SessionFactory sessionFactory = configuration.buildSessionFactory(registry); Session session = sessionFactory.getCurrentSession(); Transaction tx = session.beginTransaction(); Students s1 = new Students("s0000001", "小明", "男", new Date(), "北京"); Students s2 = new Students("s0000002", "小李", "男", new Date(), "南京"); Students s3 = new Students("s0000003", "小张", "男", new Date(), "上海"); Students s4 = new Students("s0000004", "小明", "男", new Date(), "北京"); Students s5 = new Students("s0000005", "小李", "男", new Date(), "南京"); Students s6 = new Students("s0000006", "小张", "男", new Date(), "上海"); Students s7 = new Students("s0000007", "小明", "男", new Date(), "北京"); Students s8 = new Students("s0000008", "小李", "男", new Date(), "南京"); Students s9 = new Students("s0000009", "小张", "男", new Date(), "上海"); session.save(s1); session.save(s2); session.save(s3); session.save(s4); session.save(s5); session.save(s6); session.save(s7); session.save(s8); session.save(s9); tx.commit(); } @Test public void testQueryAllStudent(){ StudentsDao dao = new StudentsDaoImpl(); List<Students> list = dao.queryAllStudent(); for (int i =0;i<list.size();i++) { System.out.println(list.get(i)); } } }