search

Home  >  Q&A  >  body text

android-studio - 在Android Studio边开发边测试?开发方法?

Android开发新手在使用Android Studio进行开发的时候遇到一个问题
我在开发一个app的时候用到一个以前没有使用过的控件,在代码敲完之后,想要测试一下可用性,但是数据来源于数据库,而数据库相关代码还没写好,请问怎么测试这个控件呢?或者是有其它更好更规范的开发方法?谢谢!

怪我咯怪我咯2772 days ago526

reply all(6)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 09:06:41

    I’m a novice with an undergraduate degree, so I’ll give this a forced answer, because what I wrote is all about demos and I haven’t made any actual products.
    Database access operations are all SqlHelper中进行的,getUsers返回List<User>。数据库方面还没确定代码的话,可以直接new出一个模拟的List<User>returned to the caller.

    List<User> ret = new ArrayList<User>();
    ret.add(new User(1, "Alice"));
    ret.add(new User(2, "Bob"));
    return ret;

    reply
    0
  • 迷茫

    迷茫2017-04-18 09:06:41

    We usually use fake data for processing, like what is written above. There are many database frameworks for Android now, such as activeAndroid, realm, ormLite, which are very convenient to use and very powerful.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:06:41

    As mentioned above, write a simple simulation data generation method

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-18 09:06:41

    The data is not very important, just simulate it directly. What you want to test is the control! !

    reply
    0
  • 迷茫

    迷茫2017-04-18 09:06:41

    Use ContentProvider to encapsulate database operations

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 09:06:41

    Generally this is called mock, which is to fake a similar interface, but the data is hard-coded in the memory. For example, you open an array to store all data, and then write a Mock class to provide a database interface. This can also be applied to network requests

    reply
    0
  • Cancelreply