8000 Release/9.7.0 by JorelAli · Pull Request #618 · CommandAPI/CommandAPI · GitHub
[go: up one dir, main page]

Skip to content

Release/9.7.0 #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 64 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b38936a
Set version to 9.6.2-SNAPSHOT
JorelAli Oct 28, 2024
558f09c
Create `commandapi-bukkit-test-toolkit`
willkroboth Jul 4, 2024
1816bff
Add `MockCommandAPIPlugin` for testing with `commandapi-bukkit-plugin`
willkroboth Jul 5, 2024
9ad579f
Add `assertCommandSucceeds` and `assertCommandFails` methods to Comma…
willkroboth Jul 5, 2024
8ed2acf
Add `assertCommandRunsWithArguments` methods to CommandAPITestUtilities
willkroboth Jul 9, 2024
d2fa55e
Implement testing IntegerRangeArgument NMS independently
willkroboth Jul 9, 2024
b86eb60
Fix CommandAPIHandler javadoc error that breaks full build
willkroboth Jul 9, 2024
be330ca
Add `assertCommandSuggests` methods to CommandAPITestUtilities
willkroboth Jul 10, 2024
7178477
Add `assertCommandFailsWithArguments` methods
willkroboth Jul 10, 2024
dafa99a
Improve coverage report by using Supplier<String> in CommandAPITestUt…
willkroboth Jul 10, 2024
83e5133
Add example argument and suggestion tests
willkroboth Jul 10, 2024
363c247
Add EntitySelectorArgument, PlayerArgument, and OfflinePlayerArgument…
willkroboth Jul 13, 2024
874770b
Implement Argumen 8000 tType suggestions for test toolkit
willkroboth Jul 16, 2024
2824ed8
Refactor Parser building syntax
willkroboth Jul 17, 2024
421fa57
Add README files for the test toolkit example projects
willkroboth Jul 17, 2024
4b67594
Add javadocs for important test toolkit methods and classes
willkroboth Jul 18, 2024
2ab0c17
Add docs for the test toolkit
willkroboth Jul 19, 2024
3b92c11
Fix trailing space (markdown lint)
willkroboth Jul 19, 2024
7b5750a
Add manual update notes to `update.sh`
willkroboth Jul 22, 2024
6b5f791
Allow developers to load custom MockCommandAPIBukkit instances in the…
willkroboth Aug 24, 2024
3b74499
Use translation keys instead of literal messages
willkroboth Sep 23, 2024
c8264e3
Update note about unimplemented methods in test_intro.md
willkroboth Sep 23, 2024
764f72e
Update MockBukkit-v1.21 to match paper updates
willkroboth Sep 23, 2024
5b286a3
Add javadocs to ArgumentUtilities and parser package
willkroboth Oct 6, 2024
87406f3
Update dependencies to 1.21
willkroboth Oct 16, 2024
40e8f87
Add @n to suggestions
willkroboth Oct 16, 2024
e9003b5
Add braces to inlined if-statements
willkroboth Oct 16, 2024
d2a8f88
Update documented dependency versions and mention gradle dependencies
willkroboth Oct 16, 2024
461f9f9
Fix markdownlint errors in test_setup.md
willkroboth Oct 16, 2024
ba8d578
Update MockBukkit to fix Paper 1.21 api update
willkroboth Oct 22, 2024
ac84d75
Rework `Parser` definition
willkroboth Oct 25, 2024
0bb04fa
Fix test-toolkit dependencies
willkroboth Oct 26, 2024
8688a08
Code review
willkroboth Oct 26, 2024
cf61f14
Update test toolkit versions to 9.6.2-SNAPSHOT manually
willkroboth Oct 28, 2024
e000a4b
Add new 9.6.0 NMS methods to MockCommandAPIBukkit
willkroboth Oct 28, 2024
c53e451
Merge pull request #575 from JorelAli/dev/simple-test-suite
willkroboth Oct 28, 2024
b27fc71
complete #529
MC-XiaoHei Nov 13, 2024
a47d939
format, docs, and fix tests
MC-XiaoHei Nov 15, 2024
1582991
format
MC-XiaoHei Nov 15, 2024
ab330ee
use const for more readable
MC-XiaoHei Nov 15, 2024
2c9b081
Update commandapi-core/src/main/java/dev/jorel/commandapi/AbstractArg…
MC-XiaoHei Nov 18, 2024
fd2eca8
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 18, 2024
90e6045
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 18, 2024
994653c
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 18, 2024
d0dd2c8
add thenNested() list ver, implement array ver with list ver
MC-XiaoHei Nov 18, 2024
0203144
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 19, 2024
3a8a6f2
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 19, 2024
59572b2
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 19, 2024
a31e859
implement nested { } with list ver thenNested() method
MC-XiaoHei Nov 19, 2024
54d3e36
Update commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/…
MC-XiaoHei Nov 19, 2024
8771911
fix indentation
MC-XiaoHei Nov 20, 2024
50fa068
fix indentation
MC-XiaoHei Nov 20, 2024
27b9360
Merge pull request #613 from MC-XiaoHei/dev/dev
JorelAli Nov 20, 2024
082bee7
Initial work for 1.21.4 support
DerEchtePilz Dec 3, 2024
0cb559a
Adds documentation for Trail particle and adds thenNested to the docu…
JorelAli Dec 3, 2024
362b8e6
Add 1.21.4 to the issue template
DerEchtePilz Dec 3, 2024
32319cf
Add test toolkit to 9.7.0 documentation changelog
willkroboth Dec 4, 2024
6017fd0
Set version to 9.7.0
JorelAli Dec 4, 2024
28cc2f5
Adds 9.7.0 documentation
JorelAli Dec 4, 2024
e79fb6e
Update homepage to point to 9.7.0
JorelAli Dec 4, 2024
aea0a3e
Generate 9.7.0 JavaDocs
JorelAli Dec 4, 2024
2e3adc2
Update documentation wiki.vg links to point to the MinecraftWiki wiki…
JorelAli Dec 4, 2024
7fe69b7
Merge branch 'master' into release/9.7.0
JorelAli Dec 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add assertCommandSucceeds and assertCommandFails methods to Comma…
…ndAPITestUtilities

Add DispatchCommandUtilitiesTests to fully test these methods

Add CommandTestBase to provide utilities when testing the test toolkit

Enable Jacoco code coverage report for `commandapi-test-toolkit`

Add some comments
  • Loading branch information
willkroboth committed Oct 28, 2024
commit 9ad579faf6b68f7c325ef5c5a5227d6323320f2c
6 changes: 6 additions & 0 deletions commandapi-codecov/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-test-toolkit</artifactId>
<version>${project.version}</version>
<!-- This should not have the test scope because it contains classes whose coverage we want to analyze -->
</dependency>

<!-- From commandapi-bukkit-nms-dependency-mojang-mapped -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,15 @@
</dependencies>

<build>
<!-- Fill ${project.version} in plugin.yml -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering> <!-- Fill ${project.version} in plugin.yml -->
<filtering>true</filtering>
</resource>
</resources>

<!-- Remove commandapi-core's VersionHandler in favor of ours -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -107,7 +110,6 @@
<goal>shade</goal>
</goals>
<configuration>
<!-- Remove commandapi-core's VersionHandler in favor of ours -->
<filters>
<filter>
<artifact>dev.jorel:commandapi-core</artifact>
Expand All @@ -133,8 +135,37 @@
<version>3.3.0</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
<!-- To help with debugging tests, you can specify an include
to limit a build to only run a certain test file. Uncomment
here if you want to do that: -->
<!-- <includes>-->
<!-- <include>**/DispatchCommandUtilitiesTests.java</include>-->
<!-- </includes>-->
</configuration>
</plugin>

<!-- Run code coverage report -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<!-- to avoid bugs in some situations -->
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- create report during maven verify phase -->
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
package dev.jorel.commandapi;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import org.bukkit.command.CommandSender;
import org.opentest4j.AssertionFailedError;

import static org.junit.jupiter.api.Assertions.fail;
import java.util.Objects;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class CommandAPITestUtilities {
public static MockCommandAPIBukkit getCommandAPIPlatform() {
return MockCommandAPIBukkit.getInstance();
}

public static void dispatchCommand(CommandSender sender, String command) {
try {
dispatchThrowableCommand(sender, command);
} catch (CommandSyntaxException exception) {
fail(
"Expected command dispatch to succeed." +
" If you expected this to fail, use `dispatchFailableCommand` instead.",
exception
);
}
public static void dispatchCommand(CommandSender sender, String command) throws CommandSyntaxException {
getCommandAPIPlatform().getBrigadierDispatcher().execute(command, new MockCommandSource(sender));
}

public static void dispatchThrowableCommand(CommandSender sender, String command) throws CommandSyntaxException {
getCommandAPIPlatform().getBrigadierDispatcher().execute(command, new MockCommandSource(sender));
public static void assertCommandSucceeds(CommandSender sender, String command) {
assertDoesNotThrow(
() -> dispatchCommand(sender, command),
"Expected command dispatch to succeed"
);
}

@CanIgnoreReturnValue
public static CommandSyntaxException assertCommandFails(CommandSender sender, String command, String expectedMessage) {
CommandSyntaxException exception = assertThrows(
CommandSyntaxException.class,
() -> dispatchCommand(sender, command),
"Expected command dispatch to fail"
);

String actualMessage = exception.getMessage();
if (!Objects.equals(expectedMessage, actualMessage)) {
throw new AssertionFailedError(
"Expected command dispatch to fail with message <" + expectedMessage + ">, but got <" + actualMessage + ">"
);
}
return exception;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package dev.jorel.commandapi;

import be.seeseemelk.mockbukkit.MockBukkit;
import be.seeseemelk.mockbukkit.ServerMock;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import org.junit.jupiter.api.function.Executable;
import org.opentest4j.AssertionFailedError;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

public abstract class CommandTestBase extends CommandAPITestUtilities {
// Setup
protected ServerMock server;
protected MockCommandAPIPlugin plugin;

public void setUp() {
server = MockBukkit.mock();
plugin = MockBukkit.load(MockCommandAPIPlugin.class);
}

public void tearDown() {
MockBukkit.unmock();
}

// Additional test utilities
@CanIgnoreReturnValue
public <T extends Throwable> T assertThrowsWithMessage(Class<T> exceptionClass, Executable executable, String expectedMessage) {
T exception = assertThrows(exceptionClass, executable);
assertEquals(expectedMessage, exception.getMessage());
return exception;
}

@CanIgnoreReturnValue
public AssertionFailedError assertAssertionFails(Executable executable, String expectedMessage) {
return assertThrowsWithMessage(AssertionFailedError.class, executable, expectedMessage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package dev.jorel.commandapi;

import be.seeseemelk.mockbukkit.entity.PlayerMock;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Tests for the methods provided by {@link CommandAPITestUtilities} that handle dispatching commands.
*/
class DispatchCommandUtilitiesTests extends CommandTestBase {
// Setup
@BeforeEach
public void setUp() {
super.setUp();

new CommandAPICommand("ping")
.executes((sender, args) -> {
sender.sendMessage("pong!");
})
.register();
}

@AfterEach
public void tearDown() {
super.tearDown();
}

// Tests
@Test
void testAssertCommandSucceeds() {
PlayerMock player = server.addPlayer();

// Successful use of `assertCommandSucceeds`
assertCommandSucceeds(player, "ping");
player.assertSaid("pong!");

// Unsuccessful use of `assertCommandSucceeds`
assertAssertionFails(
() -> assertCommandSucceeds(player, "pong"),
"Expected command dispatch to succeed " +
"==> Unexpected exception thrown: " +
"com.mojang.brigadier.exceptions.CommandSyntaxException: Unknown command at position 0: <--[HERE]"
);
player.assertNoMoreSaid();
}

@Test
void testAssertCommandFails() {
PlayerMock player = server.addPlayer();

// Successful use of `assertCommandFails`
assertCommandFails(
player, "pong",
"Unknown command at position 0: <--[HERE]"
);

// Unsuccessful uses of `assertCommandFails`
assertAssertionFails(
() -> assertCommandFails(player, "ping", "Wrong command"),
// Command actually did not fail
"Expected command dispatch to fail ==> " +
"Expected com.mojang.brigadier.exceptions.CommandSyntaxException to be thrown, but nothing was thrown."
);
player.assertSaid("pong!");

assertAssertionFails(
() -> assertCommandFails(player, "pong", "Wrong command"),
// Command failed, but not with the given expected message
"Expected command dispatch to fail with message <Wrong command>, but got <Unknown command at position 0: <--[HERE]>"
);

player.assertNoMoreSaid();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Tests for loading the {@link MockCommandAPIPlugin}.
*/
class MockCommandAPIPluginLoadingTests {
// Setup
@BeforeEach
public void setUp() {
MockBukkit.mock();
Expand All @@ -19,6 +23,7 @@ public void tearDown() {
MockBukkit.unmock();
}

// Tests
@Test
void testMockBukkitLoad() {
MockCommandAPIPlugin plugin = MockBukkit.load(MockCommandAPIPlugin.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static dev.jorel.commandapi.CommandAPITestUtilities.dispatchCommand;
import static dev.jorel.commandapi.CommandAPITestUtilities.assertCommandSucceeds;

class PingPongCommandTests {
private ServerMock server;
Expand All @@ -30,7 +30,7 @@ public void tearDown() {
void runCommand() {
PlayerMock player = server.addPlayer();

dispatchCommand(player, "ping");
assertCommandSucceeds(player, "ping");

player.assertSaid("pong!");
player.assertNoMoreSaid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static dev.jorel.commandapi.CommandAPITestUtilities.dispatchCommand;
import static dev.jorel.commandapi.CommandAPITestUtilities.assertCommandSucceeds;

class PingPongCommandTests {
private ServerMock server;
Expand All @@ -34,7 +34,7 @@ public void tearDown() {
void runCommand() {
PlayerMock player = server.addPlayer();

dispatchCommand(player, "ping");
assertCommandSucceeds(player, "ping");

player.assertSaid("pong!");
player.assertNoMoreSaid();
Expand Down
0