warnet-gi / WarnetBot

A bot for Warga Nusantara Teyvat (WARNET) discord server
https://discord.gg/warnet-gi
MIT License
7 stars 4 forks source link

Implement Test Driven Development #54

Open Iqrar99 opened 1 year ago

Iqrar99 commented 1 year ago

This is gonna be a huge project because we need to make sure some of the logic is performing the way it should be.

image

Iqrar99 commented 1 year ago

Reading resources:

rafiramadhana commented 11 months ago

I think it is better to divide this issue into sub-issues

i.e.

So the PRs can be done per-modules

I am willing to contribute for initiating the unit tests

However, I need your help to prioritize which modules that should be test-covered first

Iqrar99 commented 11 months ago

On the second thought, i've been researching about performing testing on discord bot till now. The blocker is it's still quite hard to figure out how to test the bot command manually since it involved discord API during the process. There are some limitations that the discord.py library can do.

But there is a library called dpytest that support this issue although it's still in development and pretty hard to use. Thus, we need to wait till everything is ok to continue the testing.

Or perhaps we can move to the alternative solution. We create our own mocking object by using https://docs.python.org/3/library/unittest.mock.html (I prefer this way)

rafiramadhana commented 11 months ago

Or perhaps we can move to the alternative solution. We create our own mocking object by using https://docs.python.org/3/library/unittest.mock.html (I prefer this way)

Agree, I think using a generic mocking library like unittest.mock is a good idea

rafiramadhana commented 11 months ago

It looks like the core logic for this code base is located in bot/cogs/.... I think we can start from there for the TDD implementation.