Stephcraft / Project-16x16

2D Platformer game made with processing
GNU General Public License v3.0
97 stars 77 forks source link

Unit tests needed #162

Open danmigdev opened 2 years ago

danmigdev commented 2 years ago

We should add unit tests for existing codebase in order to have a coverage of 80% at least.

Each test class should test the related src class and be located under same package. E.g. Tile.java src class is under project_16x16.components package (src/project_16x16/components directory). TileTest.java test class must be under project_16x16.components package (test/project_16x16/components directory).

Test class name must have the suffix Test added to the source class under test. E.g. Tile.java src class to be tested must have a TileTest.java test class.

vlad-nitu commented 2 years ago

Unit tested Tile.java class and created PR for it (see #164)

danmigdev commented 2 years ago

Thanks for contribution! Hope it will be accepted. In order to improve code quality, I'd remove test word from method name (it is redundant) and use a self explaining format like [Calling]<METHOD>_[With<PARAMETERS or CONDITION>_]<EXPECTED_RESULT>

void getIDTest() -> CallingGetId_returnsId

Look here for some examples https://medium.com/@stefanovskyi/unit-test-naming-conventions-dd9208eadbea

vlad-nitu commented 2 years ago

@redcloud80 thanks for the additional reading material, I'll have your note in mind when naming other test methods in the future (as I find getters test names to be self-explanatory).

danmigdev commented 2 years ago

Classes that need to be covered with a first unit test iteration:

PLEASE RESERVE A TASK IN ORDER TO AVOID CODING TASK OVERLAPPING BETWEEN DEVELOPERS.

micycle1 commented 2 years ago

At this stage your time would better spent developing the game, rather than adding tests.

danmigdev commented 2 years ago

I will for sure but testing is something that shouldn't be separated from feature implementation. I wouldn't release new features with no tests.

calfaand commented 2 years ago

Hello, can I contribute to this project with writing tests ?

danmigdev commented 2 years ago

Hello, can I contribute to this project with writing tests ?

Hi, which class would you like to take care of? Open a specific issue for the task please.