Reputation: 26054
I have this unit tests:
@Test
public void shouldReturnTheSameStringSinceHasNoAccents() {
String data = "Hola";
String expected = "Hola";
String actual = normalizer.stripAccents(data);
assertEquals(expected, actual);
}
@Test
public void shouldStripAccent() {
String data = "¿Qué haces?";
String expected = "¿Que haces?";
String actual = normalizer.stripAccents(data);
assertEquals(expected, actual);
}
I'm using Maven Surefire Plugin. If I do mvn clean package test
by terminal, I get an error in the second test:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.grupogimeno.parse.util.StringNormalizerTests
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.039 sec <<< FAILURE!
Results :
Failed tests:
shouldStripAccent(com.grupogimeno.parse.util.StringNormalizerTests)
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0
On the other hand, I have this Maven based Run/Debug Configuration in IntelliJ:
And when I click on run, both tests pass!
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.grupogimeno.parse.util.StringNormalizerTests
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.093 sec
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
Both ways are using the M2_HOME
env var to execute mvn
.
What is happening?
Thanks.
Upvotes: 1
Views: 2271
Reputation: 12501
It might be caused by source code encoding, see https://maven.apache.org/general.html#encoding-warning and add following property to your pom:
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Upvotes: 1