Code Monkey home page Code Monkey logo

mammoth's Introduction

mammoth

GitHub Workflow Status (branch) MIT License

Plugin Utilities

The main component of mammoth is utility functions for developing Gradle plugins in java, plus ProjectPlugin, an interface for plugins for Project instances.

Functional Testing

Mammoth provides test fixtures to enable functional testing of Gradle plugins. This architecture is designed for Java tests using JUnit 5, with the buildscripts for tested builds stored as classpath resources. This stands in contrast to Groovy functional tests, where the buildscript is written as a string directly in the test class.

Annotations

Annotation Purpose
@GradleFunctionalTest Mark a test method as a functional test
@GradleParameters Pass parameters to every Gradle invocation
@TestVariant Declare a single variant of a tent, with a specific gradle version and extra parameters. Repeatable
@TestVariantResource Declare a classpath resource to read additional variants from. Each line in the file is one variant, in the format <version>[:<args...>]

Usage

Example

Assuming there are files at src/test/resources/com/example/myplugin/simpleBuild/in/build.gradle and src/test/resources/com/example/myplugin/simpleBuild/in/settings.gradle, the following sets up a simple test that will run on both Gradle 6.9 and 7.1:

com/example/myplugin/MyPluginTest.java:

/**
 * A <em>meta-annotation</em> containing our test configuration.
 */
@GradleFunctionalTest
@GradleParameters({"--warning-mode", "all", "--stacktrace"}) // parameters for all variants
@TestVariant(gradleVersion = "6.9")
@TestVariant(gradleVersion = "7.1")
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD})
public @interface MyPluginTest {
}

com/example/myplugin/MyPluginFunctionalTest.java

class MyPluginFunctionalTest {

  @MyPluginTest
  void simpleBuild(final TestContext ctx) {
    ctx.copyInput("build.gradle");
    ctx.copyInput("settings.gradle");

    final BuildResult result = ctx.build("build"); // or anoher

    assertEquals(TaskOutcome.SUCCESS, result.task(":build").getOutcome());
    
    // Use any other methods on TestContext to help validate output.
  }
}

mammoth's People

Contributors

kashike avatar powercasgamer avatar renovate-bot avatar renovate[bot] avatar zml2008 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mammoth's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/build.yml
gradle
settings.gradle
  • org.gradle.toolchains.foojay-resolver-convention 0.7.0
build.gradle
gradle/libs.versions.toml
  • org.jetbrains:annotations 24.1.0
  • org.junit:junit-bom 5.10.1
  • ca.stellardrift:stylecheck 0.2.1
  • com.google.errorprone:error_prone_core 2.24.1
  • com.puppycrawl.tools:checkstyle 10.12.7
  • net.ltgt.errorprone 3.1.0
  • net.kyori.indra 3.1.3
  • net.kyori.indra.checkstyle 3.1.3
  • net.kyori.indra.licenser.spotless 3.1.3
  • net.kyori.indra.publishing.sonatype 3.1.3
  • io.github.gradle-nexus.publish-plugin 2.0.0-rc-1
  • com.diffplug.spotless 6.21.0
mammoth-test/build.gradle
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.3

  • Check this box to trigger a request for Renovate to run again on this repository

ProjectOrSettingsPlugin

a plugin that can be applied to either a project or a settings instance, with the conveniences of mammoth

mammoth-test: Test coverage

It would be good to test the testing framework -- I'm not sure the best way to do that though, since we would want to test JUnit behavior from within JUnit.

Maybe we'd just have simple test cases that use the helpers?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.