-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
18 save to file unit tests #130
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For writing tests against filecontent with assertJ the method Assertions.linesOf(Path) is needed to avoid using File from java.io. Not available before 3.23.0.
To be able to specify a path to a test folder during test running a new method will be added called setDir(Path). Default folder will still be used in user home folder if not specifying a Path with setDir. Also removes \n from writeString call that otherwise creates an empty line at the end.
Adds two test one for a successful save and one for trying to save to an invalid folder so no file can be created.
Adds new test that changes user.home property to run more code.
Rewritten testmethods that can test saving to file by changing 'user.home' property.
kappsegla
force-pushed
the
18-save-to-file-unit-tests
branch
from
February 15, 2023 21:21
af46e15
to
bd8b5f1
Compare
# Conflicts: # src/main/java/org/fungover/haze/Main.java # src/main/java/org/fungover/haze/SaveFile.java # src/test/java/org/fungover/haze/SaveFileTest.java
Remove \\ from path. Works in windows but not on linux file systems.
xCandyFun
force-pushed
the
18-save-to-file
branch
from
February 16, 2023 07:49
590a689
to
5a1c590
Compare
…-file-unit-tests # Conflicts: # src/main/java/org/fungover/haze/SaveFile.java # src/test/java/org/fungover/haze/SaveFileTest.java
cchriss123
approved these changes
Feb 16, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job. Code works and looks great.
RobertMili
approved these changes
Feb 16, 2023
Kudos, SonarCloud Quality Gate passed! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tried writing some tests for save to file that @xCandyFun has made a PR for, using TempDir from junit5 and changing user.home path while running tests. Achieved over 95% test coverage this way, without having to make the code under test more test friendly.
Also included a version bump of AssertJ so we can use Assertions.linesOf with Path to verify file content in a test.
This is just an example of how it is possible to verify file manipulation and saving in an easy way using AssertJ library.
Feel free to include this code in the project by merging it into the haze/18-save-to-file branch before accepting #117 or updating that PR with commits directly.