Ensure consistency in the test case execution environment #1809
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am running faces TCK tests in the GlassFish project using the following command:
Encountered failure while running the Issue2754IT test case.
View line 43 of test case Issue2754IT
This line of code is checking whether the return message of the page contains a specified string. Through debugging, it was found that in my runtime environment, the content returned by page.asNormalizedText() is:
Apparently, the return messages have been internationalized.
I went to check the mojarra project's definition of the return message, and in the English environment, the fields defined in the Messages.properties file are used :
The environment I'm running tests in is macOS, and the country setting is "China", so I'll use the Messages_zh_CN.properties .
In fact, in this test case, the content of page.asNormalizedText() is as expected, but because it returns a Chinese string, it causes a wrong judgment.
We can keep GlassFish using consistent locale settings for any language environment on any operating system by setting the JVM parameters:
This way all tests are run in a consistent environment.
Fortunately, GlassFish's arquillian plugin supports setting the JVM parameters via environment variables glassfish.systemProperties
So, you can set the
glassfish.systemProperties
property in the pom:This way, arquillian will convert
glassfish.systemProperties
to JVM parameters when starting GlassFish.In addition, on macOS, the value of Locale.getDefault() cannot be influenced by setting the environment variable LC_ALL:
On Linux, it is possible to change the Locale.getDefault() via the environment variable LC_ALL.
So, I think setting JVM parameters is a more prudent approach to keep all environments consistent.