Getting the following error trying to run the test task in my gradle java project.
Task 'test' not found in project ':app'.
* Try:
> Run gradle tasks to get a list of available tasks.
> For more on name expansion, please refer to https://docs.gradle.org/8.13/userguide/command_line_interface.html#sec:name_abbreviation in the Gradle documentation.
> 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.
> Get more help at https://help.gradle.org.
BUILD FAILED in 294ms
My build.gradle file:
import org.gradle.api.tasks.testing.logging.TestLogEvent
buildscript {
ext {
jdom_version = '2.0.6.1'
junit_version = '4.13.2'
mockito_version = '5.18.0'
}
}
plugins {
id 'java-library'
id 'application'
}
repositories {
gradlePluginPortal()
mavenCentral()
}
version = '0.0.1'
java {
sourceCompatibility = JavaVersion.VERSION_17
withSourcesJar()
}
dependencies {
implementation "org.jdom:jdom2:$jdom_version"
implementation files ('lib/DlpUtilities-1.0.0.jar', 'lib/DiceUtilities-1.0.0.jar')
testImplementation "junit:junit:$junit_version"
testImplementation "org.mockito:mockito-core:$mockito_version"
}
sourceSets {
main {
java {
srcDir 'app/src/main'
}
}
test {
java {
srcDir 'app/src/test'
}
}
}
test {
maxParallelForks = 1
testLogging {
events TestLogEvent.FAILED, TestLogEvent.SKIPPED
}
}
Output of gradle tasks:
------------------------------------------------------------
Tasks runnable from root project '****'
------------------------------------------------------------
Application tasks
-----------------
run - Runs this project as a JVM application
Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the classes of the 'main' feature.
sourcesJar - Assembles a jar archive containing the main sources.
testClasses - Assembles test classes.
Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.
Distribution tasks
------------------
assembleDist - Assembles the main distributions
distTar - Bundles the project as a distribution.
distZip - Bundles the project as a distribution.
installDist - Installs the project as a distribution as-is.
Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the 'main' feature.
Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project '****'.
dependencies - Displays all dependencies declared in root project '****'.
dependencyInsight - Displays the insight into a specific dependency in root project '****'.
help - Displays a help message.
javaToolchains - Displays the detected java toolchains.
outgoingVariants - Displays the outgoing variants of root project '****'.
projects - Displays the sub-projects of root project '****'.
properties - Displays the properties of root project '****'.
resolvableConfigurations - Displays the configurations that can be resolved in root project '****'.
tasks - Displays the tasks runnable from root project '****' (some of the displayed tasks may belong to subprojects).
Verification tasks
------------------
check - Runs all checks.
test - Runs the test suite.
Rules
-----
Pattern: clean<TaskName>: Cleans the output files of a task.
Pattern: build<ConfigurationName>: Assembles the artifacts of a configuration.
To see all tasks and more detail, run gradle tasks --all
To see more detail about a task, run gradle help --task <task>
BUILD SUCCESSFUL in 956ms
1 actionable task: 1 executed