Skip to content

Changes

Started 22 hr ago
Took 38 sec on Builder

Summary

  1. Fix test environment writing config files to project root (commit: 2ec35ed) (details)
Commit 2ec35ed0ccaf797a613d963f9cdc490cd05f403d by nossr50
Fix test environment writing config files to project root

BukkitConfig calls mcMMO.p.getDataFolder() in its constructor to
determine where to write config files. When tests mock mcMMO.p but
don't stub getDataFolder(), it returns null, which Java resolves to
the current working directory (the project root), causing files like
experience.yml to be created there.

Fix by stubbing mcMMO.p.getDataFolder() with a fresh temporary
directory in every test setup that mocks mcMMO.p:
- MMOTestEnvironment.mockBaseEnvironment(): creates testDataFolder
  in temp and deletes it in cleanUpStaticMocks()
- SQLDatabaseManagerTest.setUpAll(): same pattern, cleaned in tearDownAll()
- FlatFileDatabaseManagerTest.initBeforeAll(): same pattern, cleaned
  in the new tearDownAll() method

Also remove the .gitignore band-aid entries that were added to paper
over the symptom.
(commit: 2ec35ed)
The file was modifiedsrc/test/java/com/gmail/nossr50/database/SQLDatabaseManagerTest.java (diff)
The file was modified.gitignore (diff)
The file was modifiedsrc/test/java/com/gmail/nossr50/database/FlatFileDatabaseManagerTest.java (diff)
The file was modifiedsrc/test/java/com/gmail/nossr50/MMOTestEnvironment.java (diff)