jwi*_*ir3 7 testing junit android unit-testing
我一直在看这个答案:https://stackoverflow.com/a/2055455/281460,它很好地解释了Android中单元/集成测试可用的不同测试类.但是,它没有解释的一件事是InstrumentationTestCase,与其他测试用例类之间的区别,特别是AndroidTestCase.
有人可以对此有所了解吗?
来自文档:
可以访问Instrumentation的测试用例.
如果您需要访问依赖于Activity Context的Resources或其他内容,请扩展此项.
AndroidTestCase通过您发布的链接很好地总结了.InstrumentationTestCase来自于类层次结构的更高层次ActivityInstrumentationTestCase2.它比普通的重量更重AndroidTestCase,但它只暴露一个Instrumentation物体而不是Activity限制它的用途.
实际上,您可能永远不需要这个类,因为它不提供太多(如果有的话)性能优势ActivityInstrumentationTestCase2,它提供了Instrumentation对象本身的访问.在任何情况下,如果您想知道Instrumentation对象可以做什么,请查看这个或这个.