gpt4 book ai didi

android - InstrumentationTestCase 和 AndroidTestCase 的区别

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:54:08 25 4
gpt4 key购买 nike

我一直在看这个答案:https://stackoverflow.com/a/2055455/281460它很好地解释了可用于 Android 单元/集成测试的不同测试类。不过,它没有解释的一件事是 InstrumentationTestCase 和其他测试用例类之间的区别,特别是 AndroidTestCase

有人可以阐明这一点吗?

最佳答案

来自文档:

InstrumentationTestCase

A test case that has access to Instrumentation.

AndroidTestCase

Extend this if you need to access Resources or other things thatdepend on Activity Context.

AndroidTestCase 通过您发布的链接得到了很好的总结。 InstrumentationTestCaseActivityInstrumentationTestCase2 类层次结构的更高层。它比普通的 AndroidTestCase 更重,但它只公开了一个 Instrumentation 对象,没有公开 Activity,限制了它的实用性。

实际上,您可能永远不需要这个类,因为与 ActivityInstrumentationTestCase2 相比,它并没有提供太多(如果有的话)性能优势,后者提供对 Instrumentation 的访问> 对象本身。无论如何,如果您想知道可以用 Instrumentation 对象做什么,请查看 this。或 this .

关于android - InstrumentationTestCase 和 AndroidTestCase 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26470674/

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