• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / IntegratedDynamics / 20210191346

14 Dec 2025 03:32PM UTC coverage: 19.514% (-33.5%) from 53.061%
20210191346

push

github

rubensworks
Remove deprecations

663 of 8728 branches covered (7.6%)

Branch coverage included in aggregate %.

6786 of 29445 relevant lines covered (23.05%)

1.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.0
/src/main/java/org/cyclops/integrateddynamics/gametest/integration/IntegrationMethodGameTestInstance.java
1
package org.cyclops.integrateddynamics.gametest.integration;
2

3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.MapCodec;
5
import com.mojang.serialization.codecs.RecordCodecBuilder;
6
import net.minecraft.core.Holder;
7
import net.minecraft.gametest.framework.*;
8
import net.minecraft.network.chat.Component;
9
import net.minecraft.network.chat.MutableComponent;
10
import net.minecraft.resources.ResourceLocation;
11
import org.cyclops.integrateddynamics.core.test.IntegrationBefore;
12
import org.cyclops.integrateddynamics.core.test.IntegrationTest;
13

14
import java.lang.reflect.InvocationTargetException;
15
import java.lang.reflect.Method;
16
import java.util.List;
17
import java.util.Locale;
18

19
/**
20
 * @author rubensworks
21
 */
22
public class IntegrationMethodGameTestInstance extends GameTestInstance {
23

24
    public static final MapCodec<? extends GameTestInstance> CODEC = RecordCodecBuilder.<IntegrationMethodGameTestInstance>mapCodec(instance -> instance.group(
11✔
25
            TestData.CODEC.forGetter(IntegrationMethodGameTestInstance::info),
3✔
26
            Codec.STRING.fieldOf("modId").forGetter(IntegrationMethodGameTestInstance::getModId),
5✔
27
            Codec.STRING.fieldOf("class").forGetter(IntegrationMethodGameTestInstance::getClassName),
5✔
28
            Codec.STRING.fieldOf("method").forGetter(IntegrationMethodGameTestInstance::getMethodName)
3✔
29
    ).apply(instance, IntegrationMethodGameTestInstance::new));
1✔
30

31
    private final String modId;
32
    private final String className;
33
    private final String methodName;
34

35
    public IntegrationMethodGameTestInstance(TestData<Holder<TestEnvironmentDefinition>> info, String modId, String className, String methodName) {
36
        super(info);
×
37
        this.modId = modId;
×
38
        this.className = className;
×
39
        this.methodName = methodName;
×
40
    }
×
41

42
    public String getModId() {
43
        return modId;
×
44
    }
45

46
    public String getClassName() {
47
        return className;
×
48
    }
49

50
    public String getMethodName() {
51
        return methodName;
×
52
    }
53

54
    @Override
55
    public void run(GameTestHelper gameTestHelper) {
56
        try {
57
            Class<?> clazz = Class.forName(this.className);
×
58
            Object instance = clazz.newInstance();
×
59

60
            // Call befores
61
            List<Method> befores = com.google.common.collect.Lists.newLinkedList();
×
62
            for(Method method : clazz.getDeclaredMethods()) {
×
63
                if(method.isAnnotationPresent(IntegrationBefore.class)) {
×
64
                    befores.add(method);
×
65
                }
66
            }
67

68
            Method method = clazz.getMethod(this.methodName);
×
69

70
            gameTestHelper.succeedIf(() -> {
×
71
                GameTester.GAME_TEST_HELPER = gameTestHelper;
×
72
                try {
73
                    for(Method before : befores) {
×
74
                        before.invoke(instance);
×
75
                    }
×
76
                    method.invoke(instance);
×
77
                } catch (InvocationTargetException e) {
×
78
                    Class<?> excepted = method.getAnnotation(IntegrationTest.class).expected();
×
79
                    if(!excepted.isInstance(e.getTargetException())) {
×
80
                        if (e.getTargetException() instanceof IllegalStateException || e.getTargetException() instanceof AssertionError) {
×
81
                            e.getTargetException().printStackTrace();
×
82
                            throw new GameTestAssertException(Component.literal("Test " + getId().toString() + " failed!"), (int) gameTestHelper.getTick());
×
83
                        } else {
84
                            e.getTargetException().printStackTrace();
×
85
                            throw new GameTestAssertException(Component.literal(String.format("Expected at %s exception %s, but found:", getId().toString(), e)), (int) gameTestHelper.getTick());
×
86
                        }
87
                    }
88
                } catch (IllegalAccessException e) {
×
89
                    e.printStackTrace();
×
90
                    throw new GameTestAssertException(Component.literal(e.getMessage()), (int) gameTestHelper.getTick());
×
91
                }
×
92
            });
×
93
        } catch (IllegalAccessException | ClassNotFoundException | InstantiationException | NoSuchMethodException e) {
×
94
            e.printStackTrace();
×
95
            throw new GameTestAssertException(Component.literal(e.getMessage()), (int) gameTestHelper.getTick());
×
96
        }
×
97
    }
×
98

99
    @Override
100
    public MapCodec<? extends GameTestInstance> codec() {
101
        return CODEC;
×
102
    }
103

104
    @Override
105
    protected MutableComponent typeDescription() {
106
        return Component.literal("Method-based test instance for " + getClassName() + "." + getMethodName());
×
107
    }
108

109
    public ResourceLocation getId() {
110
        return ResourceLocation.fromNamespaceAndPath(this.modId, (this.className.replaceAll("org.cyclops\\.[^.]*\\.[^.]*\\.", "") + "." + this.methodName).toLowerCase(Locale.ROOT).replace('.', '_'));
×
111
    }
112
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc