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

Setup Gradle functional tests #4074

Merged
merged 3 commits into from
Nov 15, 2021
Merged

Setup Gradle functional tests #4074

merged 3 commits into from
Nov 15, 2021

Conversation

3flex
Copy link
Member

@3flex 3flex commented Aug 26, 2021

This is a step on the way to separating Gradle TestKit tests from the other Gradle plugin tests (see #3778).

This PR sets up the Gradle build to support the new structure, and moves tests that use TestKit but don't use dry-run mode into src/functionalTest. It also moves shared code into src/testFixtures so they can be used by both functional tests and standard tests while that's still necessary.

There's a new task functionalTest which runs all tests in src/functionalTest. Both functionalTest and test are dependencies of check task and therefore also the build task.

@codecov
Copy link

codecov bot commented Aug 26, 2021

Codecov Report

Merging #4074 (c387461) into main (231ba0f) will increase coverage by 84.27%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #4074       +/-   ##
===========================================
+ Coverage        0   84.27%   +84.27%     
- Complexity      0     3249     +3249     
===========================================
  Files           0      471      +471     
  Lines           0    10261    +10261     
  Branches        0     1805     +1805     
===========================================
+ Hits            0     8647     +8647     
- Misses          0      664      +664     
- Partials        0      950      +950     
Impacted Files Coverage Δ
...sch/detekt/rules/style/UnnecessaryAbstractClass.kt 84.78% <0.00%> (ø)
...osch/detekt/rules/style/OptionalAbstractKeyword.kt 89.47% <0.00%> (ø)
...lin/io/gitlab/arturbosch/detekt/rules/TypeUtils.kt 100.00% <0.00%> (ø)
...turbosch/detekt/rules/style/UseIfEmptyOrIfBlank.kt 80.00% <0.00%> (ø)
...bosch/detekt/formatting/wrappers/ImportOrdering.kt 100.00% <0.00%> (ø)
...b/detekt/metrics/processors/ProjectLOCProcessor.kt 100.00% <0.00%> (ø)
...in/kotlin/io/gitlab/arturbosch/detekt/core/Junk.kt 100.00% <0.00%> (ø)
...lab/arturbosch/detekt/rules/style/VarCouldBeVal.kt 89.58% <0.00%> (ø)
...n/kotlin/io/github/detekt/tooling/api/DetektCli.kt 100.00% <0.00%> (ø)
...b/detekt/tooling/internal/DefaultAnalysisResult.kt 87.50% <0.00%> (ø)
... and 461 more

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 231ba0f...c387461. Read the comment docs.

@3flex 3flex added the housekeeping Marker for housekeeping tasks and refactorings label Aug 26, 2021
@chao2zhang
Copy link
Member

IntelliJ IDE does not really like addition test source set like intTest. I just applied this PR locally and the problem mentioned in #3504 still persists.

I am thinking if we should start experimenting with extracting integration tests into a separate module as discussed in #3324 (comment).

@3flex
Copy link
Member Author

3flex commented Aug 29, 2021

I just applied this PR locally and the problem mentioned in #3504 still persists.

I'm not seeing that - which IDE specifically (IntelliJ, Android Studio) & which version? Can you try deleting the .idea directory and clean IDE cache?

I have no red underline in any files under /src/intTest (IntelliJ IDEA 2021.2.1) with almost all settings at defaults:
image

@chao2zhang
Copy link
Member

After ./gradlew clean and removing .idea, the IDE does not seem to intTest as a test module (With green background).
image
Previously IntelliJ cannot infer the module dependencies correctly, and now after regenerating the .idea folder, it seems to work for me for the most part.

@3flex
Copy link
Member Author

3flex commented Aug 30, 2021

I think as long as the Spek IDE plugin can pick up the tests, Gradle executes them and IDE indexing works, the fact that it's not specifically identified as green/test module isn't a showstopper (it does bug me as well though! But this setup is simpler to me than having a whole new module for integration tests)

We can have others weigh in of course.

@cortinico
Copy link
Member

the fact that it's not specifically identified as green/test module isn't a showstopper

Agree. Also I believe you can workaround the coloring issue with something like:

idea.module {
    sourceDirs.remove(file("src/intTest/kotlin"))
    testSourceDirs.add(file("src/intTest/kotlin"))
}

Sadly I wasn't able to let it work (see https://youtrack.jetbrains.com/issue/IDEA-151925). If you folks look into it let me know 🙏

@3flex 3flex changed the title Setup Gradle integration tests Setup Gradle functional tests Sep 11, 2021
@cortinico cortinico added this to the 1.19.0 milestone Sep 18, 2021
@3flex
Copy link
Member Author

3flex commented Sep 23, 2021

Converting back to draft and removing from 1.19.0 milestone (for now) - Gradle 7.3 is introducing support for test suites which I believe supersedes the currently recommended configuration I've used here.

It would be better to wait to see what that looks like and use the newer, hopefully simpler setup.

@3flex 3flex removed this from the 1.19.0 milestone Sep 23, 2021
@3flex 3flex marked this pull request as draft September 23, 2021 05:34
@chao2zhang
Copy link
Member

@3flex Would you mind sharing some of the pointers how Gradle 7.3 changes the test suites? (Assuming this is for Gradle integration test only)

@3flex 3flex force-pushed the inttest branch 5 times, most recently from b11b720 to 1409591 Compare October 4, 2021 12:14
@3flex
Copy link
Member Author

3flex commented Oct 12, 2021

Would you mind sharing some of the pointers how Gradle 7.3 changes the test suites?

https://docs.gradle.org/7.3-rc-1/release-notes.html#test-suites

@3flex 3flex force-pushed the inttest branch 2 times, most recently from 7a235e6 to b79c62d Compare October 12, 2021 10:45
@cortinico
Copy link
Member

Great stuff! What's the status on the IDE support?

@3flex 3flex force-pushed the inttest branch 2 times, most recently from 146b506 to 4350fc2 Compare October 21, 2021 00:18
@3flex
Copy link
Member Author

3flex commented Oct 21, 2021

What's the status on the IDE support?

Unfortunately it's not configured automatically but I've requested this integration & configuration be applied automatically: gradle/gradle#18723

@3flex 3flex marked this pull request as ready for review November 10, 2021 01:48
detekt-gradle-plugin/build.gradle.kts Show resolved Hide resolved
detekt-gradle-plugin/build.gradle.kts Show resolved Hide resolved
@chao2zhang chao2zhang added this to the 1.19.0 milestone Nov 15, 2021
@3flex 3flex merged commit 001c50c into detekt:main Nov 15, 2021
@3flex 3flex deleted the inttest branch November 15, 2021 08:23
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.

4 participants