小编ven*_*ore的帖子

未解决的参考:测试

我正在尝试在我当前在Kotlin中编写的android项目中编写简单的集成测试.

问题是测试没有事件启动并因以下错误而失败:

Error:(4, 36) Unresolved reference: testing
Error:(18, 52) Unresolved reference: InstantTaskExecutorRule
Error:Execution failed for task ':app:kaptGenerateStubsDebugAndroidTestKotlin'.
> Compilation error. See log for more details
Run Code Online (Sandbox Code Playgroud)

我试过谷歌搜索这个问题,但没有成功.

我已经尝试过的步骤:

  1. 检查是否安装了包含InstantTaskExecutorRule的库,我可以深入了解这个包(是的,我可以)
  2. 检查我的测试是否放在正确的文件夹中(是的,它在androidTest)
  3. 检查我是否正确启动了测试(可能是我通过右键单击包启动它们pkgName (androidTest)然后"在...中运行测试")

我也尝试将我的源目录从java重命名为koltin,并设置正确的值sourceSets但由于没有成功而将其更改回来,并认为这不是原因.

重要通知:

如果我评论该行import android.arch.core.executor.testing.InstantTaskExecutorRule和所有代码InstantTaskExecutorRule(意味着整个测试逻辑将为空)并放置一个简单assert的例子,那么一切正常.

但是我想用这个特别的东西InstantTaskExecutorRule,想知道问题到底是什么以及如何解决它,或者至少知道我应该在哪里找什么.

这是我的测试代码:

import android.arch.core.executor.testing.InstantTaskExecutorRule
import android.arch.persistence.room.Room
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4

import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import com.myapp.storage.base.AppDataBase


@RunWith(AndroidJUnit4::class)
class UserDaoTest{
    @JvmField @Rule val instantTaskExecutorRule = …
Run Code Online (Sandbox Code Playgroud)

android integration-testing kotlin android-architecture-components

12
推荐指数
2
解决办法
5055
查看次数

本地通知不在设备上工作,但在模拟器上工作

我已经阅读了一些如何使用UILocalNotification的指南.所以自从我第一次尝试以来,我已经尝试过并且没有成功.要在AppDelegate.m中注册通知,我使用:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    ...
    //if it is iOS 8
    if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])
    {
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge|UIUserNotificationTypeAlert|UIUserNotificationTypeSound) categories:nil];
        [application registerUserNotificationSettings:settings];
    }
    else // if iOS 7
    {
        UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
        [application registerForRemoteNotificationTypes:myTypes];
    }

    UILocalNotification *locationNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
    if (locationNotification) {
        // Set icon badge number to zero
        application.applicationIconBadgeNumber = 0;
        }

        return YES;
    }
Run Code Online (Sandbox Code Playgroud)

并在应用程序运行时收到通知:

    - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
    {
    NSLog(@"notification recieved %@",notification.alertBody);
     // …
Run Code Online (Sandbox Code Playgroud)

background objective-c ios uilocalnotification ios-simulator

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

无法启动凤凰发布

昨天我遇到了一个非常奇怪的问题.

组态:

- Erlang 19
- Elixir 1.3.1
- Exrm 1.0.6
- Phoenix 1.2.0
- Ubuntu 15.10
Run Code Online (Sandbox Code Playgroud)

步骤:

  1. 使用编译项目 MIX_ENV=prod mix compile
  2. 使用构建版本 MIX_ENV=prod mix release
  3. 尝试使用测试构建的项目 rel/susu_online/bin/susu_online console

然后我得到一个错误,无法弄清楚为什么会发生这种情况

以下错误:

Erlang/OTP 19 [erts-8.0] [source-6dc93c1] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]

10:37:29.758 [error] Supervisor 'Elixir.Logger.Supervisor' had child 'Elixir.Logger.ErrorHandler' started with 'Elixir.Logger.Watcher':watcher(error_logger, 'Elixir.Logger.ErrorHandler', {true,false,500}, link) at <0.1445.0> exit with reason normal in context child_terminated
10:37:29.767 [info] Application lager started on node 'susu_online@127.0.0.1'
10:37:29.767 [info] Application hpack started on node 'susu_online@127.0.0.1'
10:37:29.768 [info] Application …
Run Code Online (Sandbox Code Playgroud)

elixir exrm phoenix-framework

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

TaskGroup 限制大量任务的内存使用量

我正在尝试使用现代 Swift Concurrency 构建分块文件上传机制。有一个流式文件读取器,我用它来逐块读取 1mb 大小的文件。它有两个闭包nextChunk: (DataChunk) -> Voidcompletion: () - VoidInputStream第一个被调用的次数与从块大小读取的数据一样多。

为了使该阅读器兼容 Swift Concurrency,我进行了扩展并创建了AsyncStream 似乎最适合这种情况的扩展。

public extension StreamedFileReader {
    func read() -> AsyncStream<DataChunk> {
        AsyncStream { continuation in
            self.read(nextChunk: { chunk in
                continuation.yield(chunk)
            }, completion: {
                continuation.finish()
            })
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

使用它,AsyncStream我迭代地读取一些文件并进行如下网络调用:

func process(_ url: URL) async {
    // ...
    do {
        for await chunk in reader.read() {
            let request = // ...
            _ = try await service.upload(data: chunk.data, request: …
Run Code Online (Sandbox Code Playgroud)

async-await swift structured-concurrency asyncstream asyncsequence

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

如何获取HashMap的第一个元素

尝试了很多方法并阅读了大量的文字,但我仍然无法理解如何解决我的问题.我们的想法是,HashMap中填充了一个"for"循环,其中包含来自数据库的数据.此外,此参数(HashMap)传递给listViewContent然后创建适配器并最终填充listView.事实是listView中的每一行都有2个textView和1个imageView,我需要从这个listView的第二个textView获取文本,数据存储在数据库中.

这是我的代码块:HashMap块

if (posts != null) {
    for (WallPostItem post : posts) {
        //create new map for a post
        Map<String, Object> map = new HashMap<String, Object>();
        map.put(ATTRIBUTE_NAME_TEXT, post.text);
        PictureItem postPicture = new PictureItem();
        map.put(ATTRIBUTE_NAME_IMAGE, postPicture);
        map.put(ATTRIBUTE_NAME_DATE, post.date);



        if ((post.pictures != null) && (post.pictures.size() != 0)) {
            //start downloading of pictures

            String pictureLink = post.pictures.get(0);

            if (dbHandler.hasPicture(pictureLink)) {
                Bitmap image = dbHandler.getPicture(pictureLink);
                int width = image.getWidth();
                int height = image.getHeight();
                if (width>800 || height>800){
                 int threeWidth = width / 2;
                 int …
Run Code Online (Sandbox Code Playgroud)

java android listview hashmap android-listview

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