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

Migrate detekt-gradle-plugin tests to JUnit #4529

Merged
merged 4 commits into from Feb 10, 2022

Conversation

3flex
Copy link
Member

@3flex 3flex commented Jan 26, 2022

See #4450

@3flex 3flex marked this pull request as draft January 26, 2022 03:27
@3flex 3flex mentioned this pull request Jan 26, 2022
26 tasks
@codecov
Copy link

codecov bot commented Jan 26, 2022

Codecov Report

Merging #4529 (3e12b6e) into main (7126e4b) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               main    #4529   +/-   ##
=========================================
  Coverage     84.45%   84.45%           
  Complexity     3330     3330           
=========================================
  Files           479      479           
  Lines         11143    11143           
  Branches       2040     2040           
=========================================
  Hits           9411     9411           
  Misses          699      699           
  Partials       1033     1033           
Impacted Files Coverage Δ
...osch/detekt/rules/exceptions/SwallowedException.kt 77.04% <0.00%> (ø)

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 7126e4b...3e12b6e. Read the comment docs.

@3flex 3flex added the housekeeping Marker for housekeeping tasks and refactorings label Jan 26, 2022
@3flex 3flex force-pushed the junit-gradle-plugin branch 2 times, most recently from e07a375 to 1da11fb Compare January 26, 2022 04:03
Comment on lines +79 to +85
fun scenarios(): List<Arguments> = listOf(
arguments(groovy, groovyBuildFileContent),
arguments(kotlin, kotlinBuildFileContent)
)

@ParameterizedTest(name = "Using {0}")
@MethodSource("scenarios")
Copy link
Member

Choose a reason for hiding this comment

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

Don't commit this! For sure it will not compile.

Suggested change
fun scenarios(): List<Arguments> = listOf(
arguments(groovy, groovyBuildFileContent),
arguments(kotlin, kotlinBuildFileContent)
)
@ParameterizedTest(name = "Using {0}")
@MethodSource("scenarios")
class Scenarios : ArgumentsProvider {
override fun provideArguments(context: ExtensionContext) = Stream.of(
arguments(DslTestBuilder.groovy(), groovyBuildFileContent),
arguments(DslTestBuilder.kotlin(), kotlinBuildFileContent),
)
}
@ParameterizedTest(name = "Using {0}")
@ArgumentsSource(DetektReportMergeSpec.Scenarios::class)

But what do you think of something like this? It avoid String references that are easier to break. The problem is that it's more verbose. It's just a suggestion.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the string reference is OK in this case, given the function sits directly above the test method. Also I just tried and IntelliJ will update the string in the annotation if the method is renamed using Refactor -> Rename in the IDE, and also if the string itself is renamed with Refactor -> Rename.

BraisGabin
BraisGabin previously approved these changes Jan 27, 2022
@3flex 3flex force-pushed the junit-gradle-plugin branch 4 times, most recently from f7e9c28 to 7de8135 Compare February 7, 2022 11:26
@3flex 3flex marked this pull request as ready for review February 7, 2022 22:07
@3flex 3flex dismissed BraisGabin’s stale review February 8, 2022 10:33

PR is complete so this is ready for a fresh review.

Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Generally looks good to me 👍 Diff is quite big so I haven't looked into too much details as I believe most of the changes were auto-generated.

@3flex
Copy link
Member Author

3flex commented Feb 8, 2022

Diff is quite big

Just wait for detekt-rules-style migration :D

image

(With more to do)

@cortinico
Copy link
Member

Just wait for detekt-rules-style migration :D

Ahahah my brain refuses to process whatever is above 1k loc 😅

@3flex 3flex merged commit 00a4728 into detekt:main Feb 10, 2022
Goooler pushed a commit to Goooler/detekt that referenced this pull request Feb 10, 2022
* Migrate detekt-gradle-plugin functional tests to JUnit

* Migrate detekt-gradle-plugin tests to JUnit

* Remove unused dependencies

* Removed unused function
@3flex 3flex deleted the junit-gradle-plugin branch April 13, 2022 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Marker for housekeeping tasks and refactorings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants