Java 8 CI to prevent regressions
See original GitHub issueExpected Behavior
Java 8 is tested on CI on every PR, so that breakages like #898 cannot happen.
Current Behavior
Java 11 - 18 on CI.
Fix
You can keep building on whatever Java you want, but in Gradle, specify on what JVM the tests are executed on. Gradle Test
tasks fork a separate process by default, so there’s no hit here. It should be a simple case of setting the Java launcher for the tests:
tasks.withType<Test>().configureEach {
it.javaLauncher.set(javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of("8")
})
}
Going further
You can remove all the builds from CI and just use 1 build that tests all the Javas at once… 🤯: https://jakewharton.com/build-on-latest-java-test-through-lowest-java/ Jake delivers once again! 😃
Failure Logs
I can see (by running the build on Java 8) that AGP is preventing you from that, but that needn’t be the case.
* Where:
Build file 'P:\projects\contrib\github-mockk\modules\mockk-agent-android\build.gradle.kts' line: 4
* What went wrong:
An exception occurred applying plugin request [id: 'buildsrc.convention.android-library']
> Failed to apply plugin 'com.android.internal.library'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
Your current JDK is located in P:\tools\lang\java-1.8.0_201-x64-jdk\jre
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Regression Testing: Tools and Techniques - Java Code Geeks
Regression testing ensures that the changes have not introduced new bugs in the existing features which were working fine before. Sometimes ...
Read more >Accelerate your Java pipeline with AI-assisted coding - Diffblue
Unit testing has an important role to play, accelerating cycle times by detecting regressions at the earliest possible stage. Since testing ...
Read more >Continuous Performance Regression Testing for CI/CD
Benchmarking allows developers to see the performance impact on their code. In a CI/CD pipeline, it prevents catastrophic performance drops.
Read more >Understanding and Improving Regression Test Selection in ...
Regression test selection (RTS) can reduce the costs of regression testing. ... with all three RTS tools (e.g., GIB requires Java 8), resulting....
Read more >What is Regression Testing? Test Cases (Example) - Guru99
Regression Testing means to confirm that a recent program or code change has not adversely affected existing features. In this tutorial ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Another option - use something like
@EnabledForJreRange(min = JAVA_11)
on the Android tests. I didn’t check which test runner you’re using (this is for JUnit 5 - but should be possible on others), but this allows full range of Java versions to be used in CI while skipping Android tests on incompatible versions.I’ve tried implementing this approach. It wasn’t easy because the Kotlin JVM test tasks are named dynamically, and they’re created lazily.
Unfortunately, once set up, all the tests pass - including the sealed-class tests that are supposed to be broken 😦
Here’s the updated Toolchain convention, but because it doesn’t work, I don’t want to commit it.
It provides these tasks:
checkJdk11
checkJdk17
checkJdk18
checkJdk8
checkJdks
- runs allcheckJdk*
tasksjvmTestJdk11
jvmTestJdk17
jvmTestJdk18
jvmTestJdk8
testJdk11
testJdk17
testJdk18
testJdk8