Unit Test for Localization

Hi everyone,

my unit tests are failing in Edit Mode Test Runner because my tests can’t get the strings from the database of the LocalizationSettings. Is there a way or solution to mock the LocalizationSettings or wait for the Initialization Task?

The tests fail when calling this method:

public static async Task GetText(TableReference table, TableEntryReference key, params object[ ] arguments)
{
return await LocalizationSettings.StringDatabase.GetLocalizedStringAsync(table, key, arguments).Task;
}

Kind regards,
Phuc

Hi,
We do have Editor support coming in the future so this should just work then.
It is possible to mock. You would need to mock
LocalizationSettings.GetInitializationOperation.
Override the ILocalesProvider and StringDatabase.
It would be simpler to just mock your own GetText function instead. Does it need the correct text?
Can your text be a player test?