Skip to content

Commit d2cf2d7

Browse files
Add readme file (#43)
* Add the readme file * Add missing method to the readme --------- Co-authored-by: theEvilReaper <[email protected]>
1 parent a90e18a commit d2cf2d7

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Cyano
2+
3+
Cyano is a testing module extracted from the Minestom fork Microtus, which has been abandoned for an indefinite period.
4+
The reasons for this abandonment are complex and will not be discussed here.
5+
6+
## Overview
7+
8+
This project addresses the need for continued support of enhanced testing capabilities that were previously available in
9+
a now-abandoned fork. While Minestom has its own testing module, the fork included several improvements and
10+
quality-of-life features. Since some projects depend on these enhanced testing features, we've extracted them to this
11+
standalone repository to prevent breaking changes.
12+
13+
Cyano preserves all functionality from the original enhanced testing module while incorporating relevant upstream
14+
changes from Minestom. This gives you both the familiar features you depend on and the latest improvements from the main
15+
repository.
16+
17+
## Getting Started
18+
19+
To use Cyano in your tests, you'll need to include it through your build system and use the appropriate annotation.
20+
21+
### Basic Test Setup
22+
23+
Integration tests with Cyano begin with this annotation:
24+
25+
```java
26+
import net.minestom.testing.extension.MicrotusExtension;
27+
28+
@ExtendWith(MicrotusExtension.class)
29+
class MyTestClass {
30+
// Your test methods here
31+
}
32+
```
33+
34+
The `MicrotusExtension` serves as the entry point for the testing module and follows JUnit 5's extension architecture.
35+
36+
> [!IMPORTANT]
37+
> The `@ExtendWith` annotation must be placed above the class declaration, or the testing framework integration will
38+
> fail.
39+
40+
## Enhanced Features
41+
42+
### Simplified Player Creation
43+
44+
Cyano includes quality-of-life improvements not found in the upstream Minestom testing module. You can now create
45+
players without specifying spawn coordinates. The system will automatically use `(0, 0, 0)` as the default position.
46+
47+
```java
48+
// Creates a player that spawns at coordinates (0, 0, 0)
49+
Player player = env.createPlayer(instance);
50+
```
51+
52+
If you are creating a player via a `TestConnection`, there is also a method which uses a default position:
53+
54+
```java
55+
// Creates a player that spawns at coordinates (0, 0, 0)
56+
TestConnection connection = env.createConnection();
57+
Player player = connection.connect(instance);
58+
```
59+
60+
This simplification is particularly useful in tests where player positioning is irrelevant to the functionality being
61+
tested.
62+
63+
### Improved Test Cleanup
64+
65+
Managing test cleanup can be challenging, especially when dealing with instances that have active players. Minestom
66+
prevents instance destruction while players remain connected, which can lead to frustrating test failures.
67+
68+
Cyano addresses this with an enhanced `destroyInstance()` method:
69+
70+
```java
71+
// Automatically removes all players before destroying the instance
72+
env.destroyInstance(instance, true);
73+
```
74+
75+
When the boolean parameter is set to `true`, all players on the instance are automatically removed before destruction,
76+
eliminating cleanup-related issues.
77+
78+
## Migration Guide
79+
80+
Migrating from the standard Minestom testing module to Cyano is straightforward:
81+
82+
1. **Change the annotation**: Replace your existing test extension annotation with
83+
`@ExtendWith(MicrotusExtension.class)`
84+
2. **Optional enhancements**: The new features (simplified player creation and improved cleanup) are opt-in. If you
85+
don't use them explicitly, your existing tests will continue to work with their original behavior.
86+
87+
## Compatibility
88+
89+
Cyano maintains full backward compatibility with existing Minestom tests. Developers must explicitly use all enhanced
90+
features. The default behavior remains unchanged, ensuring your existing test suites continue to work without
91+
modification.

0 commit comments

Comments
 (0)