Skip to content

Add game and junit tests to AP #562

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

Draft
wants to merge 81 commits into
base: dev/0.8
Choose a base branch
from
Draft

Add game and junit tests to AP #562

wants to merge 81 commits into from

Conversation

SirEndii
Copy link
Member

@SirEndii SirEndii commented Feb 23, 2024

This PR aims to add the long needed game tests to AP. It's still a draft.
We will use the Testing Framework from CC to accomplish this
The framework is implemented, and I started to work on the first tests

  • Checklist
  • - Add JUnit tests for common AP functions
  • - Mod Integrations
      • - Botania
      • - AE 2
      • - Note Blocks
      • - Beacons
      • - RS (currently not possible)
      • - Create
      • - Mekanism
      • - Powah
      • - Minecolonies (currently not possible)
  • - Peripherals
      • - Environment Detector
      • - Chat Box
      • - Player Detector
      • - Energy Detector
      • - Inventory Manager
      • - Redstone Integrator
      • - Block Reader
      • - Geo Scanner
      • - NBT Storage
  • - Turtles
      • - Chatty
      • - Chunky (Not possible to test)
      • - Compass
      • - Player Detector
      • - Environment Detector
      • - Geo
      • - Weak Automata
      • - OP Weak Automata
      • - Husbandry Automata
      • - OP Husbandry Automata
      • - End Automata
      • - OP End Automata
  • - Pocket Computers (?) Currently not possible without an entity that loads the pocket
      • - Chatty
      • - Player Detector
      • - Enviroment
      • - Geo
  • - Documentation

ToDos:

  • The Geo Scanner docs list a getScanCooldown method which currently does not exist in AP, so I cannot test it (the test currently uses the "internal" getOperationCooldown("scanBlocks") method)
  • The isOnEnchantedSoil function on Botania Mana Flowers always returns false, even when the flower is placed on enchanted soil. This seems to be the case because the overgrowth variable on a Mana Flower is only set to true during the flower tick (see https://github.com/VazkiiMods/Botania/blob/1.20.x/Xplat/src/main/java/vazkii/botania/api/block_entity/SpecialFlowerBlockEntity.java#L100)
  • The isEmpty method on Botania Mana Pools is currently missing
  • For the Botania Mod Integration, some methods are only available in the 1.20.1 versions of AP, so they're currently commented out in the .lua test files. When merging this to the 1.20.1 branch, these methods should be uncommented
  • Botania Mana Spreaders have a getBounding method returning the coordinates of the block that the spreader is directed towards, shouldn't it be called getBinding then?
  • The isEmpty function on Botania Mana Spreaders does not return if the mana in the spreader is empty but if the item handler of the spreader is empty
  • On Note Blocks, the method changeNoteBy is named somewhat weird. It sets the note value to the given parameter and does not change the note by x amount. Shouldn't it be called setNote or something?

SirEndii added 12 commits July 19, 2023 10:59
…s to code test the most code which does not need a running minecraft instance. For other parts of the project, gametests will be created at a later point

Also make a static helper function to create the tooltips to minimize duplication and maintenance time
# Conflicts:
#	gradle.properties
# Conflicts:
#	src/main/java/de/srendi/advancedperipherals/common/items/base/BaseBlockItem.java
#	src/main/java/de/srendi/advancedperipherals/common/items/base/BaseItem.java
…uters with CC's testing api

Removed some old stuff
@SirEndii
Copy link
Member Author

I will mark this as high priority. I will work on this asap since we really need tests for AP

@SirEndii SirEndii added Priority-High help wanted Some help is needed labels Apr 30, 2024
@SirEndii
Copy link
Member Author

SirEndii commented May 2, 2024

I've implemented (copied) the needed stuff from the test source sets, but there is currently another issue with hamcrest and junit I need to work on
I'm going to fix this asap. For now there are the cc tests in AP for testing purposes

@SirEndii
Copy link
Member Author

SirEndii commented May 3, 2024

I fixed everything that need to be fixed (I think)
The game tests are now ready to be created

SirEndii added 2 commits May 5, 2024 21:52
The test can be run via `runGameTestClient` using the /test command or `runGameTestServer` to run all the tests automatically
SirEndii and others added 5 commits May 21, 2024 17:35
…2-peripheral-tests

Revert "Revert "Implement game tests for more peripherals""
… the 1.20.x branch

This was mainly done to allow the execution of client tests
dogboy21 and others added 3 commits June 2, 2024 01:31
@SirEndii SirEndii changed the base branch from dev/1.19.2 to dev/0.8 September 7, 2024 19:04
# Conflicts:
#	build.gradle
#	gradle.properties
#	src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemUtil.java
@zyxkad
Copy link
Collaborator

zyxkad commented Sep 7, 2024

by the way why is chunky turtle not possible to test?
I think the test cases are:

  • load when server start:
    1. place turtle to (edge of/far away in) the world
    2. restart server
    3. check if the turtle id exists, and/or check if the chunk is loaded
  • unload chunk when moving/destroyed:
    1. place turtle to far away in the world
    2. make the turtle move across the border, or destroy the turtle
    3. check if the back chunk is unloaded
  • load chunk when moving:
    1. place turtle to far away in the world
    2. make the turtle move across the border
    3. check if the front/side chunk is loaded

I do not know if that's possible to do with the current test framework.

@SirEndii
Copy link
Member Author

SirEndii commented Sep 7, 2024

Okay you are right, not very complicated

@SirEndii
Copy link
Member Author

SirEndii commented Dec 4, 2024

I currently just tend to merge this, even unfinished. Imo testing is important, especially with all the new changes. But I don't have the time to implement ALL of that.
I will change my to-do list a bit and sort it by priority. Something which is annoying to test by hand should have the highest prio and vice versa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants