我正在尝试从命令行测试一个应用程序。当我在Android运行我的测试时,一切都很好。但是当我尝试运行命令时:
./gradlew test
我知道这个错误:
Task 'test' not found in root project 'mvp_kotlin_example'.
我在使用./gradlew构建或./gradlew清理时没有问题。我刚刚创建了一个项目来尝试./gradlew测试,它成功了。
在mvp_kotlin_example中,我使用Robolectric进行测试,Kotlin用于开发。
,那么如何使我的测试在命令行中工作呢?
编辑:
这是一个开
我已经创建了以下测试类。问题是没有找到DaggerTestDiComponent -即使我可以在build目录中看到它。
我看过类似的SO问题,但它们似乎与旧版本的gradle/Dagger2有关,似乎不适用(至少从我看到的情况来看)。我的应用程序Dagger代码工作正常。
public class TestMvpEngineeringPresenter {
@Mock
IMvpEngineeringView iMvpEngineeringView;
@Inject
MvpEngineeringPresenter mvpEngineeringPresenter;
@Rule
public
我有一个基于mvp的简单应用程序。为presenter编写测试。将Mockito用于模拟数据。我用ArgumentCaptor捕获视图回调数据(ArrayList)。我的测试类 @RunWith(MockitoJUnitRunner::class)
class MainPresenterTest{
@Mock
lateinit var view:MainView
@Mock
lateinit var context:Context
@InjectMocks
lateinit var presenter: MainPrese
我正在尝试对一个基本的Android应用程序进行一些单元测试。它只是登录到一些WS使用改进我的应用程序有一个MVP模式。 我在做什么? 对presenter层的调用这将调用interactor,在这里我将调用我的服务 @Override
public void doLogin(String user, String pwd, final LoginListener loginListener) {
try {
final LoginRequest request = new LoginRequest();
re
您好,我正试图在我的项目中运行示例测试类,但每次我运行它时,我都会收到这个错误: Test running failed: no test results
Empty test suit 下面是我介绍的示例测试类 import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation]
我正试图为我的android应用程序编写单元和espresso UI测试,用kotlin构建。因为在kotlin中,默认情况下每个类都是最终类,所以为了模拟最终类,我使用了支持模拟最终类的mockInline库。因为我必须同时编写单元测试和UI测试。我以下列方式添加了该库
testImplementation 'org.mockito:mockito-inline:2.13.0'
androidTestImplementation 'org.mockito:mockito-inline:2.13.0'
但是在运行UI测试时,它会抛出
More than one
我想为单元测试设置我的项目。
我试着遵循上的说明
// Unit testing dependencies
testCompile 'junit:junit:4.12'
// Set this dependency if you want to use Mockito
testCompile 'org.mockito:mockito-core:1.10.19'
// Set this dependency if you want to use Hamcrest matching
androidTestCompile 'org.hamcrest:hamcr
我找不到一个解决方案来帮助我测试我的ViewModels。我一直读到,它足以添加规则:
@get:Rule
var rule: TestRule = InstantTaskExecutorRule()
但我一直在想:
java.lang.RuntimeException: Method getMainLooper in android.os.Looper not mocked. See http://g.co/androidstudio/not-mocked for details.
我的测试课程现在看起来是这样的:
@RunWith(MockitoJUnitRunner::class)
最近我一直在和莫基托做斗争。但是,经过勇敢的努力,我使它在编译过程中没有出现错误,但在特定情况下,这个错误除外:
当我使用Mockito模拟包-私有类时,在同一个包中进行测试时,我会得到以下错误:
java.lang.UnsupportedOperationException: cannot proxy inaccessible class class [...].AndroidCalendarGenerator.ManageEventsUI.CalendarMonitorServiceConnection
at com.android.dx.stock.ProxyBuilder.bu
我正在为MVP项目的主持人编写单元测试。
class SplashPresenter {
override fun onAttach() {
if (dataManager.getAppLaunchFirstTime()) {
onAppOpenFirstTime()
} else {
// Other logic...
}
}
@VisibleForTesting
fun onAppOpenFirstTime() {
dataManager.set