mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
Configure mokitor Server mock as stubOnly (#8861)
A recent patch moved the internal unit tests to mokito, allowing deep mocking to easily setup a mocked server instance. While this change is useful, the server's Server#getItemFactory methods is one of the hottest paths during unit testing, being called numerous times by material tests. As mokito mocks keep track of each invocation to allow for verifications of invocations down the line, the server mock allocates a huge amount of memory to keep track of all invocations, ultimately leading to an OOM exception. The previous solution solved this by increasing the tests memory to 2 GB, however as of right now simply configuring the server mock as "stubOnly", properly prevents the overflow of invocation records as none of the unit test code relies on invocation verification.
This commit is contained in:
parent
08d77ce67a
commit
78f94ecb2d
2 changed files with 2 additions and 3 deletions
|
@ -38,8 +38,6 @@ subprojects {
|
|||
exceptionFormat = TestExceptionFormat.FULL
|
||||
events(TestLogEvent.STANDARD_OUT)
|
||||
}
|
||||
minHeapSize = "2g"
|
||||
maxHeapSize = "4g"
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
|
|
@ -38,6 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+import org.bukkit.plugin.PluginManager;
|
||||
+import org.bukkit.plugin.SimplePluginManager;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
+import org.mockito.Mockito;
|
||||
+
|
||||
+import static org.mockito.Mockito.any;
|
||||
+import static org.mockito.Mockito.mock;
|
||||
|
@ -52,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final Server dummyServer = mock(Server.class);
|
||||
+ final Server dummyServer = mock(Server.class, Mockito.withSettings().stubOnly());
|
||||
+
|
||||
+ final Logger logger = Logger.getLogger(DummyServer.class.getCanonicalName());
|
||||
+ when(dummyServer.getLogger()).thenReturn(logger);
|
||||
|
|
Loading…
Reference in a new issue