Skip to content

Commit

Permalink
first try of adding the alcatrazEscapee:mcjunitlib library for automa…
Browse files Browse the repository at this point in the history
…ted testing
  • Loading branch information
cech12 committed Jun 14, 2021
1 parent d027a25 commit e3f16b3
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ run

# Files from Forge MDK
forge*changelog.txt
/.mixin.out/
39 changes: 33 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
mavenCentral()
}
dependencies {
Expand All @@ -15,7 +14,7 @@ apply plugin: 'maven-publish'

version = "${mod_version}-${minecraft_version}"
group = 'cech12.ceramicbucket' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'ceramicbucket'
archivesBaseName = "${mod_id}"

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

Expand All @@ -42,7 +41,7 @@ minecraft {
property 'ceramicbucket.developmentMode', 'true'

mods {
examplemod {
ceramicbucket {
source sourceSets.main
}
}
Expand All @@ -56,23 +55,47 @@ minecraft {
property 'ceramicbucket.developmentMode', 'true'

mods {
examplemod {
ceramicbucket {
source sourceSets.main
}
}
}

def testClasses = String.join(File.pathSeparator,
"${mod_id}%%${sourceSets.main.output.resourcesDir}",
"${mod_id}%%${sourceSets.main.output.classesDirs.asPath}",
"${mod_id}%%${sourceSets.test.output.resourcesDir}",
"${mod_id}%%${sourceSets.test.output.classesDirs.asPath}")

serverTest {
parent runs.server // This run config inherits settings from the server config
workingDirectory project.file('run')
main 'com.alcatrazescapee.mcjunitlib.DedicatedTestServerLauncher' // The main class which launches a customized server which then runs JUnit tests
ideaModule "${project.name}.test" // Tell IDEA to use the classpath of the test module
property 'forge.logging.console.level', 'unittest' // This logging level prevents any other server information messages and leaves only the test output
environment 'MOD_CLASSES', testClasses
environment 'target', 'fmltestserver' // This is a custom service used to launch with ModLauncher's transforming class loader
environment 'targetModId', "${mod_id}" // Pass the mod ID directly to mcjunitlib, to find integration test classes from the mod annotation scan data
arg '--crashOnFailedTests' // Optional. Recommended when running in an automated environment. Without it, the server will continue running (and can be connected to via localhost) to inspect why tests failed.
forceExit = false // Optional. Recommended when running in an automated environment, or via the console rather than run configurations. This will allow the task to pass successfully when all tests pass. Use if you see errors along the lines of 'Gradle daemon disappeared unexpectedly'.
mods {
modid {
sources sourceSets.main, sourceSets.test
}
}
}

data {
workingDirectory project.file('run')

property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
property 'ceramicbucket.developmentMode', 'true'

args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/')
args '--mod', 'ceramicbucket', '--all', '--output', file('src/generated/resources/')

mods {
examplemod {
ceramicbucket {
source sourceSets.main
}
}
Expand All @@ -91,6 +114,8 @@ repositories {
name = "ModMaven"
url = "https://modmaven.k-4u.nl"
}
//for mcjunitlib
maven { url 'https://jitpack.io' }
}

dependencies {
Expand All @@ -104,6 +129,8 @@ dependencies {
compileOnly fg.deobf("mezz.jei:jei-${project.jei_version}:api")
// at runtime, use the full JEI jar
runtimeOnly fg.deobf("mezz.jei:jei-${project.jei_version}")

testImplementation fg.deobf("com.github.alcatrazEscapee:mcjunitlib:${project.mcjunitlib_version}")
}

// Example for how to get properties into the manifest for reading by the runtime..
Expand Down
8 changes: 8 additions & 0 deletions config/fml.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Enable forge global version checking
versionCheck = true
# does the splashscreen run
splashscreen = true
defaultConfigPath = "defaultconfigs"
# max threads for parallel loading : -1 uses Runtime#availableProcessors
maxThreads = -1

3 changes: 3 additions & 0 deletions eula.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#Mon Jun 14 20:01:56 CEST 2021
eula=true
11 changes: 7 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mod_id=ceramicbucket
mod_version=2.6.3
minecraft_version=1.16.2+
minecraft_version=1.16.5+

forge_version=1.16.2-33.0.21
forge_mappings=20200916-1.16.2
forge_version=1.16.5-36.0.4
forge_mappings=20210309-1.16.5

# jei
jei_version=1.16.2:7.1.+
jei_version=1.16.5:7.6.1.75

# mcjunitlib
mcjunitlib_version=1.4.3-1.16.5
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void addInformation(@Nonnull ItemStack stack, @Nullable World worldIn, @N
tooltip.add((new TranslationTextComponent(TropicalFishEntity.func_212327_q(i))).mergeStyle(atextformatting));
TranslationTextComponent textComponent = new TranslationTextComponent(s);
if (!s.equals(s1)) {
textComponent.appendString(", ").append(new TranslationTextComponent(s1));
textComponent.appendString(", ").appendSibling(new TranslationTextComponent(s1));
}

textComponent.mergeStyle(atextformatting);
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader="javafml"
loaderVersion="[33,)"
loaderVersion="[36,)"
issueTrackerURL="https://github.com/cech12/CeramicBucket/issues"
license="The MIT License (MIT)"
[[mods]]
Expand All @@ -15,18 +15,18 @@ license="The MIT License (MIT)"
[[dependencies.ceramicbucket]]
modId="forge"
mandatory=true
versionRange="[33.0.21,)"
versionRange="[36.0.4,)"
ordering="NONE"
side="BOTH"
[[dependencies.ceramicbucket]]
modId="minecraft"
mandatory=true
versionRange="[1.16.2,)"
versionRange="[1.16.5,)"
ordering="NONE"
side="BOTH"
[[dependencies.ceramicbucket]]
modId="jei"
mandatory=false
versionRange="[7.1.0.0,)"
versionRange="[7.6.1.75,)"
ordering="NONE"
side="BOTH"
33 changes: 33 additions & 0 deletions src/test/java/cech12/ceramicbucket/DispenserTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cech12.ceramicbucket;

import cech12.ceramicbucket.api.item.CeramicBucketItems;
import com.alcatrazescapee.mcjunitlib.framework.IntegrationTest;
import com.alcatrazescapee.mcjunitlib.framework.IntegrationTestClass;
import com.alcatrazescapee.mcjunitlib.framework.IntegrationTestHelper;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.DispenserTileEntity;
import net.minecraft.util.math.BlockPos;

import java.util.Objects;

@IntegrationTestClass("fluids")
public class DispenserTests {

@IntegrationTest("dispenser_water")
public void testDispenserPlaceWater(IntegrationTestHelper helper) {
helper.pushButton(new BlockPos(0, 1, 0));
helper.assertFluidAt(new BlockPos(1, 1, 1), Fluids.WATER, "Water should have been dispensed");
ItemStack dispenserItemStack = ((DispenserTileEntity) Objects.requireNonNull(helper.getTileEntity(new BlockPos(0, 1, 1)))).getStackInSlot(0);
helper.assertTrue(() -> !dispenserItemStack.isEmpty() && dispenserItemStack.getItem() == CeramicBucketItems.CERAMIC_BUCKET, "Empty bucket should have been remain in dispenser");
}

@IntegrationTest("dispenser_lava")
public void testDispenserPlaceLava(IntegrationTestHelper helper) {
helper.pushButton(new BlockPos(0, 1, 0));
helper.assertFluidAt(new BlockPos(1, 1, 1), Fluids.LAVA, "Lava should have been dispensed");
ItemStack dispenserItemStack = ((DispenserTileEntity) Objects.requireNonNull(helper.getTileEntity(new BlockPos(0, 1, 1)))).getStackInSlot(0);
helper.assertTrue(dispenserItemStack::isEmpty, "No bucket should have been remain in dispenser");
}

}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit e3f16b3

Please sign in to comment.