简体   繁体   中英

Create file in JUnit test case in Android

I am developing my test project to unit test my Android project.

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. 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.

More importantly, what are you trying to achieve?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM