gpt4 book ai didi

java - AssertThat 错误 : Cannot access path (java. nio.file.Path 未找到)

转载 作者:行者123 更新时间:2023-12-02 12:37:05 33 4
gpt4 key购买 nike

我想使用 Robolectric 进行单元测试,但我正在尝试使用 robolectric 进行简单的测试,但我一开始就陷入困境。我按照手册进行操作,对示例进行了同样的操作,甚至其他帖子也无法帮助我。每次我收到错误消息:无法访问路径。找不到 java.nio.file.Path 的类文件。

我的build.gradle是:

testCompile "org.robolectric:robolectric:3.3.2"
testCompile "org.robolectric:shadows-support-v4:3.3.2"
testCompile 'junit:junit:4.12'

我的测试类(class)是:

package com.dev.mann.chronoly;
import android.support.v7.widget.RecyclerView;
import org.junit.runner.RunWith;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowToast;
import org.robolectric.shadows.support.v4.SupportFragmentTestUtil;
import static
org.robolectric.shadows.support.v4.SupportFragmentTestUtil.startFragment;

@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class)
public class CrngyMasterFragmentTestClass{
private CrngyMasterFragment mFrag;
RecyclerView mMainRecyclerView;
MainActivity activity;

@Before
public void setup() {
activity = Robolectric.buildActivity(MainActivity.class).create().start().visible().get();
//SupportFragmentTestUtil.startVisibleFragment(mFrag, MainActivity.class, R.id.master_frag_container);
}


@Test
public void checkEmptyFragments() throws Exception {
//SupportFragmentTestUtil.startVisibleFragment(mFrag, AppCompatActivity.class, R.id.master_frag_container);
assertThat(true);
// check the recyclerview items
//RecyclerView recyclerView = (RecyclerView) mFrag.getActivity().findViewById(R.id.mainRecyclerView);
//assertThat(recyclerView.isShown());
}

}

但是所有设置都不起作用。非常感谢您的帮助,感谢您的帮助。

最佳答案

从评论来看,解决方案是替换该行

import static org.assertj.core.api.Assertions.assertThat;

import static org.assertj.core.api.Java6Assertions.assertThat;

根据 AssertJ documentation .

关于java - AssertThat 错误 : Cannot access path (java. nio.file.Path 未找到),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45100659/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com