Skip to content

Commit 0a9cff3

Browse files
committed
test: Flesh out the readme a little bit
1 parent 70903e3 commit 0a9cff3

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

mammoth-test/src/main/java/net/kyori/mammoth/test/TestContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public final class TestContext {
9090
* Copy a resource from the {@code <testName>/in/} directory to the run directory with no changes.
9191
*
9292
* @param name the input relative to the test's directory
93+
* @throws IOException if an error occurs writing the input file to disk
9394
* @since 1.1.0
9495
*/
9596
public void copyInput(final @NotNull String name) throws IOException {
@@ -101,6 +102,7 @@ public void copyInput(final @NotNull String name) throws IOException {
101102
*
102103
* @param fromName the name relative to the input
103104
* @param toName the name to use in the test's output directory
105+
* @throws IOException if an error occurs writing the input file to disk
104106
* @since 1.1.0
105107
*/
106108
public void copyInput(final @NotNull String fromName, final @NotNull String toName) throws IOException {
@@ -142,7 +144,7 @@ public void copyInput(final @NotNull String fromName, final @NotNull String toNa
142144

143145
/**
144146
* Expect that the contents of the output file {@code fileName} is equal to
145-
* the contents of the resource at {@code <testName>/out/<resourceName>}.
147+
* the contents of the resource at {@code <testName>/out/<resourceName>}.
146148
*
147149
* @param resourceName the name of the expected resource
148150
* @param fileName the name of the actual output file

readme.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,27 @@ The main component of `mammoth` is utility functions for developing Gradle plugi
1010

1111
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.
1212

13+
### Annotations
14+
15+
Annotation | Purpose
16+
--------------------------- | ------------------------------------------
17+
`@GradleFunctionalTest` | Mark a test method as a functional test
18+
`@GradleParameters` | Pass parameters to every Gradle invocation
19+
`@TestVariant` | Declare a single variant of a tent, with a specific gradle version and extra parameters. Repeatable
20+
`@TestVariantResource` | Declare a classpath resource to read additional variants from. Each line in the file is one variant, in the format `<version>[:<args...>]`
21+
22+
### Usage
23+
1324
<details>
1425
<summary>Example</summary>
1526

16-
Assuming there are files at `src/test/resources/com/example/myplugin/simpleBuild/in/build.gradle.kts` and `src/test/resources/com/example/myplugin/simpleBuild/in/settings.gradle.kts`, the following sets up a simple test that will run on both Gradle 6.9 and 7.1:
27+
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:
1728

1829
**com/example/myplugin/MyPluginTest.java**:
1930

2031
```java
2132
/**
22-
* A <em>meta-annotation containing our test configuration.</em>
33+
* A <em>meta-annotation</em> containing our test configuration.
2334
*/
2435
@GradleFunctionalTest
2536
@GradleParameters({"--warning-mode", "all", "--stacktrace"}) // parameters for all variants
@@ -37,10 +48,10 @@ public @interface MyPluginTest {
3748

3849
class MyPluginFunctionalTest {
3950

40-
@SpongeGradleFunctionalTest
51+
@MyPluginTest
4152
void simpleBuild(final TestContext ctx) {
42-
ctx.copyInput("build.gradle.kts");
43-
ctx.copyInput("settings.gradle.kts");
53+
ctx.copyInput("build.gradle");
54+
ctx.copyInput("settings.gradle");
4455

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

0 commit comments

Comments
 (0)