It's All Writing.

Writing makes you happy.

How to test multiple language test at Apex ( How to change using language dynamically in the test code )

Environment

  • Apex

Premise

In the present, we must change test user language at m17n testing ( like label which have to change by using language ) because the method like getLabel('key', 'language') doesn't exist in Apex.
So, dynamically changing test user language is one of solutions.

Code

gist.github.com

System.runAs(User) method changes the test user in the following block.