Skip to content
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

Additional AssetPath unit tests. #10279

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Conversation

viridia
Copy link
Contributor

@viridia viridia commented Oct 27, 2023

Objective

Additional unit test for AssetPath.

@viridia viridia force-pushed the refactor/path-tests branch from 05f70d2 to 03bf15e Compare October 27, 2023 01:53
@alice-i-cecile alice-i-cecile added A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change labels Oct 27, 2023
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are good tests! Kind of a nit, but I'd split these up into one assert per test. There's no setup and it makes debugging failures way easier.

@viridia
Copy link
Contributor Author

viridia commented Oct 27, 2023

These are good tests! Kind of a nit, but I'd split these up into one assert per test. There's no setup and it makes debugging failures way easier.

Well, I'm just following the pattern for the tests already there - admittedly I wrote most of the tests in this file, but the ones I didn't write also have multiple asserts per tests.

That being said, I understand where you are coming from. I like to write tests that are linear and which "tell a story", meaning that if you read the tests in order it's like reading documentation. The test failure report will tell you the line number, so you'll know which assert it was.

@alice-i-cecile
Copy link
Member

Yeah, I can get behind that. I wouldn't have hassled you about it if you were a new contributor / junior engineer, but I figured it's a good opportunity for a conversation :)

Definitely consistent with the existing tests. My main gripe with it is when you get multiple panics in the same test, and they could be evaluated separately, it slows down your debugging by a cycle or two. No big deal though, this LGTM :)

@viridia
Copy link
Contributor Author

viridia commented Oct 27, 2023

Test granularity is definitely more art than science!

@viridia
Copy link
Contributor Author

viridia commented Oct 27, 2023

@alice-i-cecile The more interesting question, I think, is "what else in this file should be tested?".

I generally don't like tests for simple accessors, they are just clutter and don't add value. But anything that has an algorithm, or a non-obvious assumption, is fair game.

For example, it may seem silly to write a test that tests the value of a constant - unless that constant needs to have special properties, like being a prime number. The test guards against future programmers accidentally making the number non-prime.

I'm not sure that there's much value in testing the "Display" impl, since that's mostly used for debugging.

@cart cart added this pull request to the merge queue Oct 27, 2023
Merged via the queue into bevyengine:main with commit cfcc113 Oct 27, 2023
@viridia viridia deleted the refactor/path-tests branch October 29, 2023 17:25
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
# Objective

Additional unit test for AssetPath.
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

Additional unit test for AssetPath.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants