-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Expand and improve iteminfo_tests #37823
Expand and improve iteminfo_tests #37823
Conversation
Tests item info for description, category, volume, weight, qualities and conductivity.
Include price and material in basic info test; refactor armor_info tests into one test case with two sections. All passing.
Includes tests for: - Weapon attack rating and mvoes - Techniques when wielded - Repairability and with what tools - Item description flags
There's a pretty decent chunk of tests in here now. I've leaned heavily on the Halligan bar, since it has a nice profile of useful attributes that I am guessing are likely to be stable, however a better way to write these tests would be to specifically set up the test items with desired attributes before trying to verify them in the formatted strings. A still better way would be to load test items from JSON files in |
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.
This is already looking great and will be really nice to have. Thanks for adding these.
Using compound bow to test: - reload time - firing mode - weapon mods Using pine nuts to test: - freshness/spoiled indicator
Build failures appear to be related to #37706 |
This test fails with the magiclysm mod loaded, since it inserts "enchanted tailor's kit" into the repair options. Since it's not essential, I simply took it out for now.
I see one of these has failed on the magiclysm CI (since I didn't account for the enchanted tailor's kit in my repair options - a weakness of using in-game items for testing). Anyhow I am simply removing that test scenario for now so it doesn't block the merge. |
…lysm-DDA into wapcaplet-iteminfo-tests
Co-Authored-By: Isaac Freund <ifreund@ifreund.xyz>
Co-Authored-By: Isaac Freund <ifreund@ifreund.xyz>
I see some Travis CI failures on the food freshness tests: For fresh food:
For old food:
This part is (correctly) appearing for all food tests:
Looks like these are a side effect of possible skill-spill from other tests - I see now that more skilled characters are supposed to see the more detailed spoilage estimates, per: Lines 934 to 938 in ab75d68
Should be fixed by forcing |
…into wapcaplet-iteminfo-tests
item.cpp#L934 `get_freshness_description` gives more detailed rot estimation messages to more skilled characters. Travis-CI revealed this test failing sometimes; this commit should ensure a consistent (0) skill level when testing these messages.
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.
Good catch, this looks ready for merge to me.
Summary
SUMMARY: Infrastructure "Improve test suite for item info panel"
Purpose of change
Add more (and better) test cases to tests/iteminfo_test.cpp
Some of my recent PRs have affected the item info panel, quite a critical and central component of the Cataclysm gaming experience. Feeling a sense of responsibility to add tests for my contributions (and a sense of disappointment at how few tests already existed), I've determined to improve the test coverage for this component.
Describe the solution
Add
TEST_CASE
s for major parts of the item info panel that were not yet tested. Items were chosen for being common in-game, and having qualities that I guess are unlikely to change.New tests include:
Describe alternatives you've considered
All of these tests depend on the specific attributes and qualities of in-game items, and as such may be quite fragile. If any future contributor rebalances the Halligan bar damage, or tweaks the flags on the hazmat suit, some of these tests are probably going to fail. In other words, the tests are strongly content-dependent.
For a more robust set of tests, it would be preferable to populate the
tests/data/
directory with a hierarchy of JSON files specifically for use by the test cases. Here is where I would put a "Test Halligan bar" and "Test hazmat suit" item JSON thatiteminfo_test.cpp
would load, and use for all of its formatting expectations. This would keep the tests focused on functionality, rather than content. Getting a system like that in place (and making it easy to use for new contributors) sounds like a minor project in itself, so I decided not to get sidetracked on figuring that out for this PR.These test cases are by no means comprehensive. The item info panel shows a ton of stuff, and I've only scraped the surface of what I know could be shown in different circumstances. Complete coverage was not something I considered tackling with this PR either.
Testing
Building and running test cases with
make (...) && tests/cata_test [iteminfo]
Additional context
Essentially done now, allowing time for review and feedback.
The basic theme of this PR is to test that each portion of item information is displayed, formatted, and color-coded as expected. For example, almost everything in this Halligan bar screenshot is covered by a test case now:
Thanks to the nicely organized system of
iteminfo_parts
flags defined in src/iteminfo_query.h, these test cases are quite straightforward to write and expand upon (and I believe I've left plenty of room for expansion).