小编gn *_*lry的帖子

找不到java.nio.file.Path的类文件

我正在org.assertj:assertj-core:3.6.2测试我的android项目.根据官方讨论,我应该使用带有assertj 3.x的java 8.

这是我的测试类,我正在尝试验证何时执行单击代码可以启动预期的活动.

import android.content.Intent;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowActivity;

@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21)
public class LoginActivityTest {

    @Test
    public void testBtnLogin(){
        LoginActivity loginActivity = Robolectric.setupActivity(LoginActivity.class);

        loginActivity.findViewById(R.id.btnLogin)
                .performClick();

        Intent expectedIntent = new Intent(loginActivity,MainActivity.class);
        ShadowActivity shadowActivity = Shadows.shadowOf(loginActivity);
        Intent actualIntent = shadowActivity.getNextStartedActivity();
        Assertions.assertThat(actualIntent).isEqualTo(expectedIntent);
    }
}
Run Code Online (Sandbox Code Playgroud)

但是当我运行测试时,我收到了这个错误:

:app:compileDebugUnitTestJavaWithJavac (Thread[Daemon worker,5,main]) started.
:app:compileDebugUnitTestJavaWithJavac
file or directory '/home/workspace/android/AndroidLib/app/src/testDebug/java', not found
Executing task ':app:compileDebugUnitTestJavaWithJavac' (up-to-date check …
Run Code Online (Sandbox Code Playgroud)

java android android-testing assertj

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

标签 统计

android ×1

android-testing ×1

assertj ×1

java ×1