Skip to content

Add Unit tests for commands #152

Closed

Description

@Zabuzard

We should add unit tests for our commands.

I am aware that we can not cover the actual JDA integration but we should still test the application logic of our commands in an isolated fashion with unit tests.

@Heatmanofurioso proposed a JdaMock class using Mockito that tries to integrate into our existing command system for some sort of natural testing. You can get the proposed changes as PATCH file here and there is also the branch feature/add_jda_mock with all those change in them already.

Before we get started, we have to decide and align on how we want to approach this, whether a JdaMock is a good idea or maybe not. And then we have to create and/or polish a solution and finally at least add some tests for the base commands (ping, dbget, dbput, as shown by @Heatmanofurioso in the proposal).

Activity

  1. added
    enhancement
    on Sep 29, 2021
  2. added this to the Initial Setup milestone on Sep 29, 2021
  3. Tais993 commented on Oct 11, 2021

    @Tais993
    Member

    When we create a wiki for this, we should clarify it excessively that people should still test their commands on Discord.
    A lot isn't getting checked when you mock (a.e command registration), things on Discord ends like not all permissions
    We can try to mock command registration, but I'm not sure about the accuracy of everything

  4. Zabuzard commented on Oct 11, 2021

    @Zabuzard
    MemberAuthor

    Agreed. Still, I do see a big benefit in having tests covering at least the command logic itself. Like, lets say a /add 10 7 command should spit out 17. We can easily add tests for that.

    Then, if someone edits the logic in the future, the test will give him confidence that he did not break the actual logic. He should of course still test it out on the real Discord to get in JDA issues, for sure. I totally agree to that!

  5. Tais993 commented on Oct 11, 2021

    @Tais993
    Member

    👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions