rxue / java-from-scratch-to-advanced

0 stars 0 forks source link

LEARNING: system properties cache in IntelliJ Idea #6

Open rxue opened 11 months ago

rxue commented 11 months ago

TODO Add a system property x in failsafe-plugin of maven, then test it with IntelliJ IDE

Reference: https://maven.apache.org/surefire/maven-failsafe-plugin/examples/system-properties.html

rxue commented 11 months ago

Tested environment: Linux and MacBook

Problem: When running SystemPropertyIT initially for the first time, the test will pass. But if the property x of failsafe-plugin is updated with another value in the pom.xml the same test executed with IntelliJ Idea could still pass unexpectedly. Whereas, if the same is executed with mvn command through terminal the update of system property can be reflected

Analysis: My guess is the cache machenism of IntelliJ Idea : when running the test for the first time, the system property is read from the maven configuration file pom.xml and then cached into IntelliJ Idea's cache, afterwards when the test is executed again and again, the same property value is retrieved from the cache and, the cache is not updated for the second even when the system property value inside pom.xml 's failsafe-plugin is updated

Reference on the cache location of IntelliJ Idea: https://intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs

Trial and Full Proof on the Analysis I tried to search for the cached property value from the cache location of IntelliJ Idea and found it from testHistory. => Trial:

  1. close the IntelliJ Idea IDE first and then remove the testHistory directory
  2. open the IntelliJ Idea again and open the same project and then run the SystemPropertyIT test

Result: the system property is then updated

Conclusion