Search code examples
androidwindowsunit-testingjunit4robolectric

Android unit Test are passing on MAC but failing on windows


I have written the unit test cases which include access to shared preferences and encrypted shared preferences. The tests are running and passing on MAC machine. However tests are failing on windows with the exception below.

java.io.IOException: Unable to rename C:\Users<UserName>\AppData\Local\Temp\robolectric-Method_testFunction\com.example.application-dataDir\files\datastore\test_preferences.preferences_pb.tmp.This likely means that there are multiple instances of DataStore for this file. Ensure that you are only creating a single instance of datastore for this file.

I searched a lot some people say that this is a windows issue, some say this is roboelectric issue and some say we should write instrumentation test for data store. please suggest me what should I do.


Solution

  • After spending lot of time and tried so many solutions I finally found the solution. Updating the data store version from 1.0.0 to 1.1.0-dev01 worked for me. I am able to run the test cases on windows also.