Found out how - seems so obvious now!
For those who are interested, you just get the sharedPreferences, and populate it with the required data.
SharedPreferences sharedPreferences = ShadowPreferenceManager.getDefaultSharedPreferences(Robolectric.application.getApplicationContext());
sharedPreferences.edit().putString("testId", "12345").commit();
If you have a custom SharedPreferences, you should be able to do this (haven't really tested properly, but should also work)
SharedPreferences sharedPreferences = Robolectric.application.getSharedPreferences("you_custom_pref_name", Context.MODE_PRIVATE);
sharedPreferences.edit().putString("testId", "12345").commit();
Hope this has helped someone :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…