Skip to content

A Java library providing custom AssertJ assertions for Gradle plugin project tests.

License

Notifications You must be signed in to change notification settings

cthing/assertj-gradle

Repository files navigation

C Thing Software assertj-gradle

CI Maven Central Version javadoc

This Java library provides custom AssertJ assertions for Gradle plugin project tests. Assertions are provided for the following Gradle objects:

Usage

The library is available from Maven Central using the following Maven dependency:

<dependency>
  <groupId>org.cthing</groupId>
  <artifactId>assertj-gradle</artifactId>
  <version>3.0.0</version>
</dependency>

or the following Gradle dependency:

implementation("org.cthing:assertj-gradle:3.0.0")

Examples

Asserting a Gradle Project Applies a Plugin

import static org.cthing.assertj.gradle.GradleAssertions.assertThat;
...
assertThat(project).hasPlugin("java");

Multiple plugins can be checked in one call.

import static org.cthing.assertj.gradle.GradleAssertions.assertThat;
...
assertThat(project).hasPlugin("java", "checkstyle");

Asserting a Gradle Project Contains a Task With Type

assertThat(project).hasTaskWithType(MyTask.class);

Asserting a Gradle Property Contains a Specific Value

import static org.cthing.assertj.gradle.GradleAssertions.assertThat;
...
final Property<String> myProperty = project.getObjects().property(String.class).convention("abcd");
assertThat(myProperty).contains("abcd");

See the Gradle Plugin Unit Testing blog post for addtional information and examples.

Building

The library is compiled for Java 17. If a Java 17 toolchain is not available, one will be downloaded.

Gradle is used to build the library:

./gradlew build

The Javadoc for the library can be generated by running:

./gradlew javadoc

Releasing

This project is released on the Maven Central repository. Perform the following steps to create a release.

  • Commit all changes for the release
  • In the build.gradle.kts file, edit the ProjectVersion object
    • Set the version for the release. The project follows semantic versioning.
    • Set the build type to BuildType.release
  • Commit the changes
  • Wait until CI builds the release candidate
  • Run the command mkrelease assertj-gradle <version>
  • In a browser go to the Maven Central Repository
  • Log in
  • Select Publish from the menubar
  • Press Publish Component
  • Enter a name for the deployment
  • Choose the file assertj-gradle-bundle-<version>.zip
  • Press Publish Component
  • Refresh the page until the deployment has been validated
  • Press Publish
  • Refresh the page until the status is Published
  • Log out
  • Delete the file assertj-gradle-bundle-<version>.zip
  • In a browser, go to the project on GitHub
  • Generate a release with the tag <version>
  • In the build.gradle.kts file, edit the ProjectVersion object
    • Increment the version patch number
    • Set the build type to BuildType.snapshot
  • Update the CHANGELOG.md with the changes in the release and prepare for next release changes
  • Update the Usage section in the README.md with the latest artifact release version
  • Commit these changes

About

A Java library providing custom AssertJ assertions for Gradle plugin project tests.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages