如何将外部属性传递到Android测试用例?

时间:2012-12-06 17:14:31

标签: android unit-testing functional-testing

我正在编写Android测试用例,我需要传入存储在.properties文件中的用户名和ID。我尝试将它放在我的测试项目资产目录下的“user.properties”文件中,但这似乎不能用作getActivity()。getAssets()。open(“user.properties”)抛出FileNotFound异常。一个伙伴告诉我,我可以在命令行上使用“-e键值”开关和自定义仪器运行器,但这似乎比必要的工作更多。什么是最好的方法呢?

1 个答案:

答案 0 :(得分:0)

在张贴到StackOverflow之前,我应该喝咖啡!我的stoopidity是调用:getActivity()。getAssets()。open(“user.properties”)而不是:getInstrumentation()。getContext()。getAssets()。open(“user.properties”) 问题解决了!

相关问题