[英]Create file in JUnit test case in Android
I am developing my test project to unit test my Android project. 我正在开发测试项目以对Android项目进行单元测试。
In my test case, I would like to create a file in my computer eg under /Users/MyUserName/Documents/
& write some test result into this file. 在我的测试案例中,我想在我的计算机中创建一个文件,例如在
/Users/MyUserName/Documents/
下,并将一些测试结果写入该文件中。 Is it possible?? 可能吗?? How to do it??
怎么做??
protected void setUp() throws Exception {
super.setUp();
File myTestResult = CREATE_FILE_IN_MY_COMPUTER();
}
Nope. 不。 Not like that at least.
至少不是那样。 All test code runs within the phone/emulator and as such has no direct access to your computer's file system.
所有测试代码都在电话/仿真器中运行,因此无法直接访问计算机的文件系统。
You'd probably have to write a webservice that runs in your machine to which your tests send data via HTTP or similar. 您可能必须编写一个在您的计算机中运行的Web服务,您的测试将通过HTTP或类似内容向其发送数据。
More importantly, what are you trying to achieve? 更重要的是,您要达到什么目标?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.