问题标签 [activityunittestcase]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - 如何从我的 java 应用程序中运行 Android Junit Test
我想从我的 java 类运行我的 android junit 测试用例。我可以使用JUnitCore类运行方法来做到这一点,还是有其他可能的方法。
android - 使用 AppCompat 项目库进行 Android 单元测试
我有一个包含一些扩展 ActivityUnitTestCase 的单元测试的项目,但是当我安装 android-support-v7-appcomapt 项目库以使用 ActionBar 时,这些测试已经停止工作。我也有一些 ActivityInstrumentationTestCase2 测试,它们工作正常。这是我的设置
如果我不调用 startActivity,则 veActivity 为空。
我尝试了在 StackOverflow 中找到的许多建议,其中大多数都导致我遇到了这个例外。
android - Android - ActivityUnitTestCase 测试类中 startActivity 方法上的 AssertionFailedError
我正在尝试测试模块中的活动。我只是想在测试方法中开始这个活动,但我总是有一个AssertionFailedError
. 我在网上搜索了这个问题,但找不到任何解决方案。任何帮助表示赞赏。
这是我的测试课:
这是错误:
问候。
android - ActivityUnitTestCase 使用 ActionBarActivity 引发 NameNotFoundException
ActivityUnitTestCase 似乎存在一个长期悬而未决的问题,即使用清单中定义的以外的目标活动包会导致 NameNotFoundException (https://code.google.com/p/android/issues/detail? id=22737)。问题日志上有一条评论表明这不会阻止测试执行 - 这不是我在测试 ActionBarActivity 时发现的。
此处建议的解决方法(ActionBarActivity 和 ActivityUnitTest - NameNotFoundException)使用 launchActivity() 似乎排除了使用模拟上下文/应用程序。有谁知道如何在被测项目中使用分层包结构并在 AUTC 中调用 startActivity() 而不会引发异常?
unit-testing - 如何在浏览器中执行 phpunit?
我正在使用 php、mysql 和 zend 框架扩展类从事 web 应用程序项目。我的任务是为 Web 应用程序编写单元测试用例。我阅读了以下文档https://phpunit.de/manual/4.3/en/installation.html并看到了一些示例。尽管我无法完全理解。我不知道如何在浏览器中练习示例代码。所以有人指导我如何启动 phpunit 框架测试用例。还有一个更重要的是我必须编写单元测试用例的类。
android - ActivityUnitTestCase 在使用 AndroidJUnitRunner 运行时抛出 RuntimeException
我正在尝试将Espresso 2.0 的 AndoridJUnitRunner与 ActivityUnitTestCase 集成。但是,当startActivity() 尝试初始化 mMockParent = new MockParent()时,我的测试崩溃了。
这是我所做的:
使用 Intellij 14 CE 创建一个新项目并对 build.gradle 进行一些更改。
编写一个 JUnit4 风格的单元测试。
运行测试,获取堆栈跟踪。
这个堆栈跟踪实际上是重新抛出
当startActivity() 尝试初始化 mMockParent = new MockParent()时会发生这种情况:
为了让 AndroidJUnitRunner 与 ActivityUnitTestCase 一起工作,我还有什么遗漏吗?任何帮助将不胜感激。
android - getStartedActivityIntent 在使用 ActivityUnitTestCase 的单元测试用例中返回 null
我正在编写单元测试用例来测试活动。扩展 ActivityUnitTestCase 类。首先启动基本意图。然后使用 TouchUtils,执行预期的操作。我的操作中有 startActivity() 调用。在调试我能够看到的代码时,活动开始了。但是在使用getStartedActivityIntent的测试用例中,它返回 null。我必须做什么?
java - 如何在横向上运行带有活动的单元测试用例
我正在为我的 android 应用程序编写测试用例。我的一项活动在各自的文件夹中有横向和纵向 xml 文件。我只有在横向 xml 文件中有 TextView。如何通过强制横向活动来运行我的测试用例。
我在测试用例中使用了以下代码,模拟器以横向打开并立即返回纵向模式。
请帮助我如何在执行我的测试用例之前保持横向。
android - 由于“java.lang.NullPointerException”,使仪器运行失败
我正在尝试通过扩展测试类来为我的应用程序中的活动编写单元测试用例ActivityUnitTestCase
。我可以更早地成功运行测试用例,但现在我在运行它们时总是遇到异常。尽管我对处理非常熟悉,但NullPointerExceptions
我无法弄清楚导致这种情况的问题。我找不到任何类似的问题,所以我发布了这个。
堆栈跟踪显示我的代码中的这一行有一个空对象引用
但是该startActivity
方法应该获取我正在测试的活动的实例。我不确定它为什么返回 null。
这是堆栈跟踪。
这是测试类
android - 无法在 ActivityUnitTestCase 中启动 Activity
我一直在尝试Activity
从 a启动一个简单的ActivityUnitTestCase
,但没有任何成功。我想我遗漏了一些明显的东西,但我不知道它是什么......我设法从 运行活动ActivityInstrumentationTestCase2
,但不是从ActivityUnitTestCase
。我尝试启动的 Activity 包含一个 Button,单击它会启动另一个 Activity。
首先,这是我的代码ActivityUnitTestCase
:
当我运行此测试时,我收到以下错误:
junit.framework.AssertionFailedError at junit.framework.Assert.fail(Assert.java:48) at junit.framework.Assert.assertTrue(Assert.java:20) at junit.framework.Assert.assertNotNull(Assert.java:218)在 junit.framework.Assert.assertNotNull(Assert.java:211) 在 android.test.ActivityUnitTestCase.startActivity(ActivityUnitTestCase.java:147) 在 com.test.temp.TestingActivityTest.setUp(TestingActivityTest.java:27) 在 junit。 framework.TestCase.runBare(TestCase.java:132) 在 junit.framework.TestResult$1.protect(TestResult.java:115) 在 junit.framework.TestResult.runProtected(TestResult.java:133) 在 android.support.test。 internal.runner.junit3.DelegatingTestResult.runProtected(DelegatingTestResult.java:90) 在 junit.framework.TestResult.run(TestResult.java:118) 在 android.support.test.internal.runner.junit3.AndroidTestResult。run(AndroidTestResult.java:49) at junit.framework.TestCase.run(TestCase.java:124) at android.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63) at junit .framework.TestSuite.runTest(TestSuite.java:243) 在 junit.framework.TestSuite.run(TestSuite.java:238) 在 android.support.test.internal.runner.junit3.DelegatingTestSuite.run(DelegatingTestSuite.java:103 ) 在 android.support.test.internal.runner.junit3.AndroidTestSuite.run(AndroidTestSuite.java:63) 在 android.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90) 在 org. junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 在 org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 在 org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 在 org.junit.runners.ParentRunner$2.evaluate(ParentRunner .java:268) 在 org.junit.runners.ParentRunner.run(ParentRunner.java:363) 在 org.junit.runner.JUnitCore.run(JUnitCore.java:137) 在 org.junit.runner.JUnitCore.run( JUnitCore.java:115) 在 android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54) 在 android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:228) 在 android.app .Instrumentation$InstrumentationThread.run(Instrumentation.java:1741)268) 在 org.junit.runners.ParentRunner.run(ParentRunner.java:363) 在 org.junit.runner.JUnitCore.run(JUnitCore.java:137) 在 org.junit.runner.JUnitCore.run(JUnitCore.java :115) 在 android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54) 在 android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:228) 在 android.app.Instrumentation$ InstrumentationThread.run(Instrumentation.java:1741)268) 在 org.junit.runners.ParentRunner.run(ParentRunner.java:363) 在 org.junit.runner.JUnitCore.run(JUnitCore.java:137) 在 org.junit.runner.JUnitCore.run(JUnitCore.java :115) 在 android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54) 在 android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:228) 在 android.app.Instrumentation$ InstrumentationThread.run(Instrumentation.java:1741)运行(Instrumentation.java:1741)运行(Instrumentation.java:1741)
尝试启动 Activity 时测试失败。我使用了与此文档页面非常相似的代码。
谢谢