In this example:
# Run in terminal
$ ./gradlew bootRun
The project integrates JUnit 5 and Mockito testing frameworks, and uses Jacoco for code coverage analysis.
Run all tests:
# Run all unit tests
$ ./gradlew test
View test report:
# Test report location
$ open build/reports/tests/test/index.html
The project uses Jacoco plugin to generate code coverage reports:
# Generate code coverage report
$ ./gradlew jacocoTestReport
# View coverage report
$ open build/reports/jacoco/index.html
Run comprehensive quality checks (including tests, coverage and code style):
# Run all code quality checks
$ ./gradlew codeQualityCheck
The project integrates Checkstyle to ensure code quality and consistency. Checkstyle is a development tool that helps Java programmers adhere to coding standards.
You can run Checkstyle check with the following command:
# Run Checkstyle check
$ ./gradlew checkstyleMain
# Generate Checkstyle HTML report
$ ./gradlew checkstyleReport
The generated HTML report is located at build/reports/checkstyle/main.html.
The Checkstyle configuration file is located at config/checkstyle/checkstyle.xml, which uses Google Java style guide by default. You can modify this file to customize the check rules according to project requirements.
Main check rules include:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip in gradle/wrapper/gradle-wrapper.properties under project root directory, which can be slow.distributionUrl in gradle/wrapper/gradle-wrapper.properties to distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.6-bin.zip
Reference: Gradle download address.repositories { mavenLocal() maven { url "https://mirrors.cloud.tencent.com/nexus/repository/maven-public/" } mavenCentral() }
allprojects { repositories { mavenLocal() maven { url "https://mirrors.cloud.tencent.com/nexus/repository/maven-public/" } mavenCentral() } }
org.gradle.jvmargs in gradle.properties to set Xmx and Xms to appropriate values.