Skip to content

Add FileLoggingTree Unit Tests #4802

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

madhurgupta10
Copy link
Collaborator

Description
Add FileLoggingTree Unit Tests

@codecov
Copy link

codecov bot commented Feb 7, 2022

Codecov Report

Merging #4802 (26ca05e) into master (9c27f85) will increase coverage by 0.38%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #4802      +/-   ##
============================================
+ Coverage     42.28%   42.66%   +0.38%     
- Complexity     1895     1907      +12     
============================================
  Files           364      364              
  Lines         15782    15782              
  Branches       1367     1367              
============================================
+ Hits           6673     6733      +60     
+ Misses         8618     8556      -62     
- Partials        491      493       +2     
Impacted Files Coverage Δ
...ns/upload/categories/UploadCategoriesFragment.java 86.95% <0.00%> (-1.45%) ⬇️
...a/fr/free/nrw/commons/review/ReviewController.java 87.20% <0.00%> (+8.13%) ⬆️
...a/fr/free/nrw/commons/logging/FileLoggingTree.java 98.18% <0.00%> (+98.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c27f85...26ca05e. Read the comment docs.

}

@Test
fun testSetLogLevel() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

How the class stores the log level internally and what it does with it are 2 different things; I dont care too much that calling a setter stores a value, what I do care is that calls to the logger are filtered by that log level afterward. I think this test would be more informative if the verifications demonstrate that changing the log level means the internal logger is called (or not) depending on the value.

private lateinit var logger: Logger

@Before
fun setUp() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe that all of the complex reflection-based method invocations would go away if you simply planted a Timber tree as part of the setup here, and used the public API through Timber.

)
method.isAccessible = true
method.invoke(fileLoggingTree, 0, "test", "test", Throwable())
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing a verification step here?

}

@Test
fun testIsLoggableCaseTrue() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

See my thoughts on testSetLogLevel above


@Test
fun testIsLoggableCaseFalse() {
Whitebox.setInternalState(fileLoggingTree, "logLevel", Log.ASSERT)
Copy link
Collaborator

Choose a reason for hiding this comment

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

See my thoughts on testSetLogLevel above

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

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

Could anyone address psh's comments? Thanks! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants