stefanbirkner / system-rules

A collection of JUnit rules for testing code which uses java.lang.System.
http://stefanbirkner.github.io/system-rules
Other
547 stars 71 forks source link

Erroneous Unicode character decoding for Spock tests #12

Closed kriegaex closed 10 years ago

kriegaex commented 10 years ago

Hi Stefan.

I have a problem described and discussed at https://code.google.com/p/spock/issues/detail?id=337 because first I thought it was a Spock problem until I found out that it is related to your system-rules. Please just clone my repo https://github.com/kriegaex/order-generator.git, break one test, e.g. by changing

1 * bgControls.calculation(customer, month)

in the first Spock test to

2 * bgControls.calculation(customer, month)

Then just run mvn test.

Would you please investigate and fix that? Thanks.

stefanbirkner commented 10 years ago

I don't think that it is a problem of System Rules. I forked your project (stefanbirkner/order-generator@3d3ec1a7aaa8aeeee36e5decac9330fbe2fb913d), removed System Rules, removed all tests except one and let the last test fail. I still get

Failed tests:   Calculation [-customer\u002C 2](OrderGeneratorTest): Too few invocations for:

when I run mvn clean test.

If it is not a problem of Spock, it may be a problem of the gmaven or the Surefire plugin.

Any thoughts?

kriegaex commented 10 years ago

I finally got around to investigating this more systematically, and you are right: It was caused by the Surefire plugin. I noticed because by default the error was gone with Maven 3.1.1, but occurred with 3.0.5. I compared Surefire versions with mvn help:effective-pom and saw that the default in Maven 3.0.5 is Surefire 2.10 while in Maven 3.1.1 it is Surefire 2.12.4. Then I tested version by version with the older Maven, explicitly setting the Surefire Plugin version in my POM, until I found out that the bug went away from Surefire 2.12.2 to 2.12.13. In the release notes for 2.12.13 I found this fixed bug: http://jira.codehaus.org/browse/SUREFIRE-857. So the solution is to use a newer version of Surefire even if you work with Maven 3.0.x.