Unit test with unicode character passes in IntelliJ, but fails using Jenkins.

2,076 views
Skip to first unread message

Sebastian Kwiatkowski

unread,
May 12, 2012, 10:07:49 PM5/12/12
to jenkins...@googlegroups.com
Hello,

I'm trying to build a Java project with Jenkins 1.463 on Windows. One unit test source code file contains the right single quotation mark (u+2019). When I run the test in IntelliJ, it passes. However, when the test is ran as part of the Jenkins build process, it fails:

junit.framework.ComparisonFailure: expected:<[’]> but was:<[’]>

The expected value in the code is this:
private String UnescapedRightSingleQuotationMark = "’";

I have not changed any Jenkins settings other than paths to the JDK and Maven. The unit testing framework is JUnit 4.10.

Do I have to change some settings related to file encoding?

I would appreciate your help.


Thank you,

Sebastian Kwiatkowski

Ulli Hafner

unread,
May 13, 2012, 8:59:52 AM5/13/12
to jenkins...@googlegroups.com
This seems to be a problem in your build. Does the build run correctly
without jenkins on that Windows machine? Did you specify the encoding in
your pom.xml? (For some tools like checkstyle you need to add a
-Dfile.encoding="UTF-8" on the maven command line).

Ulli

Sebastian Kwiatkowski

unread,
May 13, 2012, 9:40:35 AM5/13/12
to jenkins...@googlegroups.com
Thank you for your help! I had to set the project.build.sourceEncoding property to UTF-8 in the POM. Now it works.

Sebastian 

Mark Waite

unread,
May 13, 2012, 3:22:09 PM5/13/12
to jenkins...@googlegroups.com
In the past, I had problems when the character set encoding passed to the Java compiler was different in different environments.  In our case, we were compiling in the ant script with an explicit declaration that the source files were encoded in iso-8859-1, but sometimes we omitted that encoding argument in the ant scripts, and then the compiler interpreted constants as UTF-8 instead of the iso-8859-1 in which they were actually encoded in our files.
 
You might try performing the same compile steps as Jenkins uses, but do them in a command line environment instead of doing them inside Jenkins.  If they fail the same way in your command line environment, then it may be a character set encoding difference in the build environment (like I had), rather than a difference in the test or runtime environment.
 
Mark Waite
Reply all
Reply to author
Forward
0 new messages