-1

I have a simple check with ObjectMapper.writeValueAsString for a test to verify that no input have been changed without a developer having noticed it. It works fine but the issue is that the length diffs between JUnit and Maven.

I have tried the following things to correct it:

  • Cleaned the cache of IntelliJ
  • Verified that both of them run the same version of ObjectMapper (2.14.2)
  • Removed all .m2 artifacts in case something was causing issue in there
6
  • 1
    A more probably explanation is that you're somehow reusing the instance of the ObjectMapper without noticing since IntelliJ and Maven's runners have different logic as to when they instantiate a test class. Can you share the relevant snippet? Commented Jan 15, 2024 at 9:32
  • 1
    what exactly do you mean with "JUnit and Maven"? Maven executes JUnit tests as well, so what is the other method you run JUnit tests? Commented Jan 15, 2024 at 9:32
  • @Mureinik Maybe? I have ran all of the tests as a suite in IntelliJ and that works fine but there could be something like that, I will do some testing Commented Jan 15, 2024 at 9:33
  • @cyberbrain With JUnit I mean in IntelliJ by pushing the button or through the 'Run All Tests' button when running from a module. Compared to 'mvn clean install' Commented Jan 15, 2024 at 9:34
  • Did you specify the character encoding in your tests? It would be helpful if you can provide a minimal reproducible example in your question and also add the different methods of running the test there. Commented Jan 15, 2024 at 9:40

1 Answer 1

0

Finally found it! It was locale that was playing tricks on me, in normal JUnit it defaulted to 'EN' but in maven it was 'EN_US' so appended extra characters in multiple places.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.