Am not able to run unit tests with using `./gradl...
# gradle
u
Am not able to run unit tests with using
./gradlew test
from the command line... Using
Gradle 8.14
wrote a kts project and whereas it was working before in my macOS based command line:
Copy code
./gradlew clean test
Reusing configuration cache.

BUILD SUCCESSFUL in 750ms
4 actionable tasks: 4 executed
Configuration cache entry reused.
Am able to run my tests from IntelliJ but this is all it does?
a
I assume you're using Kotlin/JVM and JUnit? By default the log level is 'lifecycle', and this level only logs failures. https://docs.gradle.org/8.14/userguide/java_testing.html#sec:test_logging You can modify what events are logged: https://docs.gradle.org/8.14/javadoc/org/gradle/api/tasks/testing/logging/TestLoggingContainer.html
u
@Adam S - Thanks for the response! This is a command line Java program using gradle kts:
Copy code
/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java application project to get you started.
 * For more details on building Java & JVM projects, please refer to <https://docs.gradle.org/8.14/userguide/building_java_projects.html> in the Gradle documentation.
 */

plugins {
    // Apply the application plugin to add support for building a CLI application in Java.
    application
}

repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()
}

dependencies {
    // Use JUnit Jupiter for testing.
    testImplementation(libs.junit.jupiter)

    testRuntimeOnly("org.junit.platform:junit-platform-launcher")

    // This dependency is used by the application.
    implementation(libs.guava)
}

// Apply a specific Java toolchain to ease working on different environments.
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(23)
    }
}

application {
    // Define the main class for the application.
    mainClass = "org.example.MyConsoleApp"
}

tasks.named<Test>("test") {
    // Use JUnit Platform for unit tests.
    useJUnitPlatform()
}
I can run it all 10 of my tests using IntelliJ but something broke from the command line and I even deleted my
.cache
folder and tried re-installing via Homebrew.
Its able to report failures but not tests passed:
Copy code
./gradlew clean test
Reusing configuration cache.

BUILD SUCCESSFUL in 720ms
I added this:
Copy code
tasks.named<Test>("test") {
    // Use JUnit Platform for unit tests.
   useJUnitPlatform()
   testLogging {
        events("passed", "skipped", "failed")
    }
}
This fixed it but it only works with:
./gradlew clean test
using
./gradlew test
, outputs only this:
Copy code
Reusing configuration cache.

BUILD SUCCESSFUL in 345ms
3 actionable tasks: 3 up-to-date
Configuration cache entry reused.
So, you have to use
clean
each time?
v
You should never need to use
clean
or you have a build bug. If you run with
--info
or
--scan
and looking at the build scan, you should see that your test task is simply up-to-date. If nothing changed, there is no point in re-executing the tests. One of the biggest strengths of Gradle is its ability to avoid unnecessary work. If you want to re-run the tests although nothing changed, just add
--rerun
after
test
which will disable the up-to-date check and build cache.