Skip to content

Automated tests #4716

Open
Open
@ZacSharp

Description

@ZacSharp

Describe your suggestion

Any feature should come with at least one automated test, which makes sure it is not obviously broken. (i.e. I want to revive #34)

The general idea is to do something similar to GameTest but on the client / integrated server. A test would start by pasting its associated schematic, then control Baritone solely via chat commands and observe the results.

The main design choices I see are:

  • How to store the schematics. Probably just use SNBT like Mojang does for GameTest
  • Where to put the tests. Probably just a separate source set which does not depend on the other source sets.
  • How to write the tests. Probably have a bunch of classes with run methods to be called on a separate thread, which is synchronized back to the game thread in some way. Full synchronization is cool but complicated (see fabric-client-gametest for really strong synchronization)
  • Use an existing framework? fabric-client-gametest is the only candidate I know so far. It provides some good features, but also seems to be really inflexible and only runs on fabric.

Unless there are comments changing that plan, I will implement a somewhat bare bones version of this. That is, a new source set depending on just minecraft with a bunch of classes with a run method to be called on a separate thread, using builtin SNBT for structures and with glue code in the launch source set.

I will also add a few fabric-only tests which require test infrastructure I cannot easily provide or which aren't worth the effort. There will be a test for chat buttons in this category (nothing else requires mouse or keyboard input) and potentially rendering tests (because comparing screenshots might be tricky). However fabric-client-gametest does not exist on 1.19.4 so this cannot be done together with the other tests.

Context

At least from what I can see, testing for Baritone generally is really poor. There are some lonely unit tests, which cannot even use anything requiring Minecraft/Baritone to be running, and that's it. Anything beyond that must be tested manually and there isn't even a list of things to look for.
When I test pull requests I generally only test the new features plus really basic functionality and I assume the situation for porting to newer versions is similar (@rfresh2?), which means even obvious regressions in niche features will not be caught.
(Also repeating the same test for the bazillionth time because I'm merging the same branches once again really does get tiring)

Feature / Todo checklist

  • Run tests at all
    • Run tests by setting an environment variable
    • Run tests by sending an ingame command
    • Be able to run tests on any server?
      • Be able to disconnect and reconnect? (for disconnectOnArrival)
  • Load structures for tests
  • Audit mixins in CI
  • Take screenshots during tests
    • Take screenshots of failed tests (or record them?)
  • Test groups which can be run separately
  • Be able to have a human in the loop as a test condition
    • No timeouts when waiting for human input
  • Interact with Baritone solely using its chat UI
    • Have a separate set of tests which have access to the Baritone instance
  • Try comparing screenshots (use fabric-client-gametest for screenshot tests?)
  • Use fabric-client-gametest to test chat buttons

Final checklist

  • I know how to properly use check boxes
  • I have not hidden any OwO's or UwU's in this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions