问题描述
我有几个简单的测试,如 assertNotNull(mActivity);
(我在读M.D.TorresAndroid应用程序测试指南)。被测活动运行正常。每一个测试运行没关系,以及。但是如果我在上一次的第二个测试运行多个测试 getActivity()
永不再来。在logcat中没有错误(最后一行启动意图......),什么都没有。调试时也无能为力,如果我踏进 getActivity()
它抱怨没有可用的源$ C $ C。结果
另一个测试项目 - 从谷歌ActivityTesting没关系运行,即使多次试验,这样的Eclipse配置正确结果。
有没有人遇到过这样的事情?
I have a couple of simple tests, like assertNotNull(mActivity);
(I'm reading M.D.Torres "Android Application Testing Guide"). The activity under test runs okay. Every single test runs okay as well. But if I run several tests at once on the second test getActivity()
never returns. No errors in logcat (last line "Starting Intent ..."), no nothing. Debugging doesn't help much either, if I step into getActivity()
it complains that there is no source code available.
Another test project - ActivityTesting from Google runs okay even with several tests, so Eclipse is configured right.
Did anybody ever encounter something like that?
推荐答案
我重新测试项目一次(如洁净室)和它的工作。然后,我比较两个项目,发现罪魁祸首。这是空的拆机:
I recreated test project once more (like "clean room") and it worked. Then I compared two projects and found the culprit. It was empty teardown:
protected void tearDown() throws Exception {
}
如果我删除它,所有的测试运行的绿色。如果我贴回去,第二次测试挂起。现在,我想读的解释,并准备将其标记为答案。
If I remove it, all tests run green. If I paste it back, second test hangs. Now I would like to read the explanation and ready to mark it as answer.
编辑:我应该叫 super.tearDown()
在拆机年底
方法。
对不起,打扰大家。
I should be calling super.tearDown()
at the end of the tearDown
method.Sorry for bothering everybody.
这篇关于在第二次测试getActivity()永远不会返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!