refactor: libwayshot tests improvements#330
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #330 +/- ##
==========================================
- Coverage 17.53% 12.25% -5.28%
==========================================
Files 20 19 -1
Lines 3005 2545 -460
==========================================
- Hits 527 312 -215
+ Misses 2478 2233 -245
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hmm, I wonder why codecov shows drop in coverage... |
|
Factual code coverage is up. I guess some computation error. Maybe realted to |
|
No... I am not favor this. Usually, we use mod test under that module, and write tests. And the module name will be always called tests... Why do we need to change the style of unit test? |
|
Yeah, that's the matter of taste, I guess. Personally I think it's just:
I don't understand why rust/go guys prefer writing tests near the normal code. Sometimes you browse through commit history and see something like 'changes xxx.rs' and think "yeah this must be the change I was looking for", but when actually checking you see only test update inside. |
|
The problem is the module name. I think you can split the unit tests to different files under tests, and make them the same name as the module that the test for For example --tests.rs Then it will be acceptable for me |
|
Yeah that sounds reasonable. I'll take a look if we can do that without separating tests in completely different crate |
|
@Decodetalkers |
|
I think they can not be end with test I think |
|
I was thinking this would conflict with files naming on above level, but it indeed works fine lol |
|
I think this pr is acceptable, but maybe we need to hear from other members |
|
Sure, I don't mind closing it if there are any objections to this refactor and since it's only matter of taste. |
|
@Shinyzenith @AndreasBackx Current way: like most rust apps, do unit tests in same files where the logic lives |
|
@Gigas002 The changes look fine to me. Though I feel like what would make the most "impact", is if we could dump a few outputs we would currently get from a few different monitor setups. If we could integrate that somehow into the testing framework, we could essentially entirely replicate the flow end to end. A tool could be created that would dump this information so when someone reports a bug, we could ask them to run the debug CLI of sorts to get the information we need, add it to the testing framework, and then run the tests on it. The files will likely be quite big so it'd be good to used zstd compression or something similar to store them in the repository. |
Refactor tests: move all test stuff into
tests.rsto not pollute logics code with tests code.If possible, I'd like to move all tests in completely different module, but rust guys consider this anti-pattern for some reason, so the only sane possible way - to keep tests in
libwayshotcrate, but in different file, at least.Also increase test coverage by adding several uncovered areas's tests.