android junit
16lz
2022-01-26
package com.wjj.junit;
import java.util.List;
import android.test.AndroidTestCase;
import android.util.Log;
public class PersonServiceTest extends AndroidTestCase{
public void test() throws Throwable{
MySQLLift db = new MySQLLift(this.getContext());
PersonService personService = new PersonService(db);
//personService.save();
List<Person> list = personService.findAll();
System.out.println("list.size()-----> " + list.size());
for(Person p : list){
System.out.println("p.getId()------> " + p.getId());
System.out.println("p.getName()-------> " + p.getName());
}
System.out.println("=========DBTest=========");
System.out.println("=========DBTest=========");
//personService.del(2);
}
public void testResultCde() throws Throwable{
PersonService personService = new PersonService();
XMLReader reader = new XMLReader();
List list = reader.getPersons(this.getClass().getClassLoader().getResourceAsStream("itcast.xml"));
System.out.println("===============XMLReaderTest============= >>>> " + list.size());
System.out.println("========XMLReaderTest=============personService");
assertEquals(10, personService.testRcde());
}
public void testResultCde1() throws Throwable{
PersonService personService = new PersonService();
assertEquals(20, personService.testRcde());
}
public void SAXPReaderTest()throws Throwable{
MySQLLift db = new MySQLLift(this.getContext());
PersonService personService = new PersonService(db);
personService.save();
Log.i("XMLReaderTest", "XMLReaderTest" );
Log.d("XMLReaderTest", "XMLReaderTest");
System.out.println("=====XMLReaderTest=====");
assertEquals(3, 1);
}
public void DBTest()throws Throwable{
MySQLLift db = new MySQLLift(this.getContext());
PersonService personService = new PersonService(db);
Person person = new Person();
person.setId(4);
person.setName("hellwoorld");
personService.update(person);
List<Person> list = personService.findAll();
for(Person p : list){
System.out.println("DBTestUpdated---> " + p.getId());
System.out.println("DBTestUpdated----> " + p.getName());
}
}
public void TestGetScorllData()throws Throwable{
MySQLLift db = new MySQLLift(this.getContext());
System.out.println("TestGetScorllData-------->");
PersonService personService = new PersonService(db);
Person person = personService.findPerson(6);
System.out.println("TestGetScorllData-----> " + person.getId());
System.out.println("TestGetScorllData-----> -- " + person.getName());
}
}
这是我写的TEST 方法类。 里面一共有6个测试方法, 但是当我右键->android junit test的时候, 他只跑前3个方法, 是怎么回事儿? 有人遇到过吗?
import java.util.List;
import android.test.AndroidTestCase;
import android.util.Log;
public class PersonServiceTest extends AndroidTestCase{
public void test() throws Throwable{
MySQLLift db = new MySQLLift(this.getContext());
PersonService personService = new PersonService(db);
//personService.save();
List<Person> list = personService.findAll();
System.out.println("list.size()-----> " + list.size());
for(Person p : list){
System.out.println("p.getId()------> " + p.getId());
System.out.println("p.getName()-------> " + p.getName());
}
System.out.println("=========DBTest=========");
System.out.println("=========DBTest=========");
//personService.del(2);
}
public void testResultCde() throws Throwable{
PersonService personService = new PersonService();
XMLReader reader = new XMLReader();
List list = reader.getPersons(this.getClass().getClassLoader().getResourceAsStream("itcast.xml"));
System.out.println("===============XMLReaderTest============= >>>> " + list.size());
System.out.println("========XMLReaderTest=============personService");
assertEquals(10, personService.testRcde());
}
public void testResultCde1() throws Throwable{
PersonService personService = new PersonService();
assertEquals(20, personService.testRcde());
}
public void SAXPReaderTest()throws Throwable{
MySQLLift db = new MySQLLift(this.getContext());
PersonService personService = new PersonService(db);
personService.save();
Log.i("XMLReaderTest", "XMLReaderTest" );
Log.d("XMLReaderTest", "XMLReaderTest");
System.out.println("=====XMLReaderTest=====");
assertEquals(3, 1);
}
public void DBTest()throws Throwable{
MySQLLift db = new MySQLLift(this.getContext());
PersonService personService = new PersonService(db);
Person person = new Person();
person.setId(4);
person.setName("hellwoorld");
personService.update(person);
List<Person> list = personService.findAll();
for(Person p : list){
System.out.println("DBTestUpdated---> " + p.getId());
System.out.println("DBTestUpdated----> " + p.getName());
}
}
public void TestGetScorllData()throws Throwable{
MySQLLift db = new MySQLLift(this.getContext());
System.out.println("TestGetScorllData-------->");
PersonService personService = new PersonService(db);
Person person = personService.findPerson(6);
System.out.println("TestGetScorllData-----> " + person.getId());
System.out.println("TestGetScorllData-----> -- " + person.getName());
}
}
这是我写的TEST 方法类。 里面一共有6个测试方法, 但是当我右键->android junit test的时候, 他只跑前3个方法, 是怎么回事儿? 有人遇到过吗?
更多相关文章
- Android中的一些方法-----生生不息
- Android(安卓)获取屏幕分辨率
- Android(安卓)Timer 实现方法
- 在android里保存数据的三种形式(Saving Data)
- Android(安卓)AsyncTask 异步任务取消
- Android(安卓)显示/隐藏 软键盘 方法
- Android(安卓)属性动画详解
- 浅谈Java中Collections.sort对List排序的两种方法
- Python list sort方法的具体使用