> 2022年8月11日 06:52,Konstantin Kolinko <knst.koli...@gmail.com> 写道: > > ср, 10 авг. 2022 г. в 13:25, Han Li <aooo...@gmail.com > <mailto:aooo...@gmail.com>>: >> >> Mark, >> >> Can I make a suggestion related to the ant build script. Can we add two >> properties to set the values of ` -Duser.language` and `-Duser.country`, >> because in the course of my testing I found that some of the unit test >> assertions are in English, but there may be cases where the values are >> converted by sm, e.g. Chinese. >> Just like this: >> Assert.assertEquals("ok”,x); >> The variable x becomes "好" after passing through the StringManager. >> >> So this makes it a bit inconvenient for non-English speaking developers to >> test. I avoid this problem by adding a statement to build.xml each time I >> run a test. >> <jvmarg value="-Duser.language=en"/> >> <jvmarg value="-Duser.country=US"/> >> >> So I was wondering if we could dynamically set these two values via >> build.properties >> >> Thanks, >> >> Han > > I think that such tests are just broken and require fixing. > > E.g. get an instance of StringManager and read the expected message from it. > > > Maybe we can add -Duser.language=zh -Duser.country=CN to ANT_OPTS in > some Buildbot configurations, to be able to detect such tests.
Sorry, my explanation may be confusing. Let me explain why with a concrete unit test. Just like this: org.apache.catalina.valves.TestErrorReportValve#testBug53071 ``` Assert.assertTrue(res.toString().contains("<p><b>Message</b> " + ErrorServlet.ERROR_TEXT + "</p>")); ``` org.apache.catalina.valves.ErrorReportValve#report ``` sb.append("<p><b>"); sb.append(smClient.getString("errorReportValve.message")); sb.append("</b> "); ``` Since the local of my OS is zh-CN, the response contains `<p><b>信息</b> .... ` instead of `<p><b>Message</b>.... ', so I’m trying to avoid this by changing user.language and user.country. Unfortunately, I can’t find any way to do this at the moment, so I have to manually modify the build.xml. Thanks, Han > > (Though > - It would be hard to read their logs, if anything happens. As the > logs will be in Chinese. > > - Such an approach assumes that there is something to detect. A > broken test is only broken for languages where translation exists and > differs from the default.) > > Best regards, > Konstantin Kolinko > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > <mailto:dev-unsubscr...@tomcat.apache.org> > For additional commands, e-mail: dev-h...@tomcat.apache.org > <mailto:dev-h...@tomcat.apache.org>