小编mac*_*iej的帖子

isIdleNow()返回true,但是从未发送过指示资源已从busy转换为idle的消息

我尝试在espresso中为我的android应用程序编写一些测试,我遇到了Idle的问题.如果我的isIdleNow()看起来像这样

public boolean isIdleNow() {
    return true;
}
Run Code Online (Sandbox Code Playgroud)

邮件已发送.但是如果IsIdleNow()必须等待某些条件(它在启动时不返回true),则不发送消息.我的代码

public class ImageViewIdlingResource implements IdlingResource {

private ImageView imageView=null;
ResourceCallback callback;
public ImageViewIdlingResource(ImageView imageView2){
    this.imageView = imageView2;
}

@Override
public String getName() {
    return "ImageViewIdlingResource";
}

@Override
public boolean isIdleNow() {
    return !imageView.isShown();
}

@Override
public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
    this.callback = resourceCallback;
}}
Run Code Online (Sandbox Code Playgroud)

并测试

public class EspressoTest extends ActivityInstrumentationTestCase2<SplashScreen> {

public EspressoTest() {
    super(SplashScreen.class);
}


@Override
public void setUp() throws Exception {
    super.setUp();
    getActivity();
    ImageViewIdlingResource imageResource = new ImageViewIdlingResource((ImageView)getActivity().findViewById(R.id.splashscreen_icon));
    Espresso.registerIdlingResources(imageResource); …
Run Code Online (Sandbox Code Playgroud)

testing android android-espresso

4
推荐指数
1
解决办法
1283
查看次数

ScottyM() 函数内的 Haskell 数据库查询

我正在尝试编写简单的 REST API。我使用 Database.SQLite.Simple、Scotty 和 Aeson。我在 ScottyM() 路由函数中遇到数据库查询问题。当我有这样的事情时

\n\n
routes :: [User] -> ScottyM ()\nroutes allUsers = do\n    get "/users/:id" $ do\n        id <- param "id"\n        json ([x | x <- allUsers, userId x == id] !! 0)\n\nmain = do\n    conn <- open "data.db"\n    users <- ( query_ conn "select id, first_name, second_name, team from users" :: IO [User] )\n    scotty 3000 (routes users)\n
Run Code Online (Sandbox Code Playgroud)\n\n

一切正常,但在这种情况下,allUsers 仅在服务器启动时更新一次。每次有人问起这个问题我都想问一下。所以我写了这个:

\n\n
routes :: Connection -> ScottyM ()\nroutes conn= do\n   get "/users/:id" $ do\n …
Run Code Online (Sandbox Code Playgroud)

sql rest haskell scotty

1
推荐指数
1
解决办法
292
查看次数

标签 统计

android ×1

android-espresso ×1

haskell ×1

rest ×1

scotty ×1

sql ×1

testing ×1