0

I would like to have some test data that are language specific, and having them in a strings.xml in specific values-LANG folders would be perfect, but I only want this test data to be available for androidTest's and not the main code. Can this be done somehow?

Thank you
Søren

Neigaard
  • 3,726
  • 9
  • 49
  • 85

1 Answers1

0

so

Could you do this and change it back after the tests are run maybe?

 Resources res = context.getResources();
 // Change locale settings in the app.
 DisplayMetrics dm = res.getDisplayMetrics();
 android.content.res.Configuration conf = res.getConfiguration();
 conf.setLocale(new Locale(language_code.toLowerCase())); // API 17+ only.
 // Use conf.locale = new Locale(...) if targeting lower versions
res.updateConfiguration(conf, dm);
  • I can change locale in my test, but what I am looking for is a way to have something like the values-LANG folder structure but ONLY for my tests, so that any localized data in there exists only for tests and not real code. – Neigaard May 01 '19 at 06:39