junit版本 Android,Android Studio 3.0“JUnit版本3.8或更高版本”

我正在使用Android studio 3.0和junit 4.12。 10.视窗

我曾尝试:

移动JUnit的依赖了(试过测试编制和实施范围) 32379d94ca7b26e4e3474e58c5f3e125.png

删除运行测试 - 编辑配置... - 全部删除在Android的JUnit和Android应用程序 ecf7d95cd60a8266eb1457e031e70364.png

我graddle看起来像这样:

apply plugin: 'kotlin'

dependencies {

implementation project(':domain')

compile fileTree(include: ['*.jar'], dir: 'libs')

testCompileOnly 'junit:junit:4.12'

testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

implementation 'com.android.support:appcompat-v7:26.1.0'

implementation 'io.reactivex.rxjava2:rxkotlin:2.1.0'

testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

testImplementation 'com.nhaarman:mockito-kotlin:1.1.0'

testImplementation 'org.amshove.kluent:kluent:1.14'

implementation 'com.google.api.client:google-api-client-repackaged-com-google-common-base:1.2.3-alpha'

implementation 'com.squareup.retrofit2:retrofit:2.3.0'

implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'

}

我的测试看起来像这样:

package ***.roompanel.data;

import com.google.gson.FieldNamingStrategy;

import com.google.gson.Gson;

import com.google.gson.TypeAdapterFactory;

import ***.roompanel.data.RestApi.ApiFieldNamingStrategy;

import ***.roompanel.data.RestApi.ApiGsonBuilder;

import ***.roompanel.data.RestApi.ApiItemTypeAdapterFactory;

import ***.roompanel.data.RestApi.ApiService;

import ***.roompanel.data.RestApi.IApiService;

import ***.roompanel.data.repository.EventRepository;

import ***.roompanel.domain.model.event.Event;

import ***.roompanel.domain.repository.IEventRepository;

import org.junit.Before;

import org.junit.Test;

import java.util.Date;

import java.util.List;

import static org.junit.Assert.assertNotNull;

public class EventRepositoryTest {

IEventRepository repo;

@Before

public void setUp() {

TypeAdapterFactory typeAdatperFactory = new ApiItemTypeAdapterFactory(); // system to

FieldNamingStrategy fieldNamingStrategy = new ApiFieldNamingStrategy();

Gson gson = new ApiGsonBuilder(typeAdatperFactory, fieldNamingStrategy).build();

IApiService service = new ApiService(gson);

this.repo = new EventRepository(service);

}

@Test

public void events_void_success() throws Exception {

Date start = new Date(2017,10,01);

Date end = new Date(2017,10,12);

List events = (List) repo.load(start, end);

assertNotNull(events);

}

}

UPDATE:

./gradlew测试

BUILD在25秒 53可操作任务成功:30执行,23升最新

堆栈跟踪:

java.lang.RuntimeException: Stub!

at junit.runner.BaseTestRunner.(BaseTestRunner.java:5)

at junit.textui.TestRunner.(TestRunner.java:54)

at junit.textui.TestRunner.(TestRunner.java:48)

at junit.textui.TestRunner.(TestRunner.java:41)

at com.intellij.rt.execution.junit.JUnitStarter.junitVersionChecks(JUnitStarter.java:224)

at com.intellij.rt.execution.junit.JUnitStarter.canWorkWithJUnitVersion(JUnitStarter.java:207)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:61)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)

2017-10-12

pandemic

+0

变化testCompileOnly到testImplementation –

+0

在我试图说 - 没有帮助 –

+0

尝试从终端.... –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值