RepoSense
RepoSense copied to clipboard
GitTestTemplate: `generateTestFileInfo` method is not reusable due to side effects
I wish to clarify why the generateTestFileInfo
method (a utility method in the test code) also updates the RepoConfiguration object used in the tests.
https://github.com/reposense/RepoSense/blob/145a1b4dda02ac9fdc42554835e7be98a534b0a0/src/test/java/reposense/template/GitTestTemplate.java#L90-L100
Shouldn't each test case update the RepoConfiguration on its own, if needed?
I.e., if a test case needs to track MAIN_AUTHOR
and FAKE_AUTHOR
, the config can be updated separately in the test case?
Alternatively, perhaps we should document why generateTestFileInfo
does this?
@jylee-git, may I check this with you?
One implication of this is whenever we extend GitTestTemplate
and form a new subclass for testing, we have to be aware that generateTestFileInfo
will modify the RepoConfiguration
Two test cases are affected if we remove line 96 and 97.
They are FileAnalyzerTest#blameTest
and FileAnalyzerTest#blameTestDateRange
I'll check if these tests could be refactored
@jylee-git @fzdy1914, I think we should remove the modifications to config
in the generateTestFileInfo
method (i.e. remove line 96 and 97)
Reason: I think the config setup should be done outside of generateTestFileInfo
so that generateTestFileInfo
can be used by more tests.
Currently, we cannot use generateTestFileInfo
in a test if these modifications to config
affect the test.
Shall we remove lines 96, and 97?
Not sure though. Many test code are written in early stage of RepoSense, so it is possible to have code that is not so sound.
If we remove the two lines in this helper method, then, it seems to be a bit meanless to have this one line code method.
Not sure the reason behind it either, seconding what @fzdy1914 said about test codes being written in the early stages.
But I agree that the config of authors and its' respective aliases should be done on individual test case itself.
And probably call respective generateFileInfo
methods directly instead of going through GitTestTemplate#generateTestFileInfo
and/or GitTestTemplate#getFileResult
if these two methods no longer serve any added value when the two lines of code are removed?
Ok, I'll take a look and see if we should remove GitTestTemplate#generateTestFileInfo
and
GitTestTemplate#getFileResult
I will be looking into this.