Project-16x16 icon indicating copy to clipboard operation
Project-16x16 copied to clipboard

Unit tests needed

Open danmigdev opened this issue 2 years ago • 8 comments

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.

danmigdev avatar Jul 09 '22 11:07 danmigdev

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

vlad-nitu avatar Jul 09 '22 23:07 vlad-nitu

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

danmigdev avatar Jul 10 '22 16:07 danmigdev

@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).

vlad-nitu avatar Jul 10 '22 16:07 vlad-nitu

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.

  • [ ] Audio.java
  • [ ] Camera.java
  • [ ] Constants.java
  • [ ] Options.java
  • [ ] PClass.java
  • [ ] SideScroller.java
  • [ ] Tileset.java
  • [ ] Utility.java
  • [ ] components/AnimationComponent.java
  • [x] ~~components/Tile.java~~ [PR waiting by @vlad-nitu]
  • [ ] entities/CleanerRobot.java
  • [ ] entities/Enemy.java
  • [ ] entities/Player.java
  • [x] ~~multiplayer/Multiplayer.java~~ [DONE by @redcloud80]
  • [ ] objects/BackgroundObject.java
  • [ ] objects/CollidableObject.java
  • [ ] objects/EditableObject.java
  • [ ] objects/EditorItem.java
  • [ ] objects/GameObject.java
  • [ ] objects/MagicSourceObject.java
  • [ ] objects/MirrorBoxObject.java
  • [ ] particleSystem/Particle.java
  • [ ] particleSystem/ParticlePreloadSystem.java
  • [ ] particleSystem/ParticleSystem.java
  • [ ] particleSystem/Particles.java
  • [ ] particleSystem/emissions/ArchEmission.java
  • [ ] particleSystem/emissions/AreaEmission.java
  • [ ] particleSystem/emissions/DirectionalEmission.java
  • [ ] particleSystem/emissions/ParticleEmission.java
  • [ ] particleSystem/emissions/RectEmission.java
  • [ ] particleSystem/emissions/RotationEmission.java
  • [ ] particleSystem/events/ParticalVelocityController.java
  • [ ] particleSystem/events/ParticleAccelerationController.java
  • [ ] particleSystem/events/ParticleAnimationController.java
  • [ ] particleSystem/events/ParticleChildController.java
  • [ ] particleSystem/events/ParticleEventListener.java
  • [ ] particleSystem/events/ParticleNoLoopController.java
  • [ ] particleSystem/events/ParticleSizeController.java
  • [ ] projectiles/MagicProjectile.java
  • [ ] projectiles/ProjectileObject.java
  • [ ] projectiles/Swing.java
  • [ ] scene/AudioSettings.java
  • [ ] scene/GameplayScene.java
  • [ ] scene/MainMenu.java
  • [ ] scene/MultiplayerClientMenu.java
  • [ ] scene/MultiplayerHostMenu.java
  • [ ] scene/MultiplayerMenu.java
  • [ ] scene/PScene.java
  • [ ] scene/PauseMenu.java
  • [ ] scene/Settings.java
  • [ ] scene/gameplaymodes/GameplayMode.java
  • [ ] scene/gameplaymodes/ImportGameMode.java
  • [ ] scene/gameplaymodes/InventoryGameMode.java
  • [ ] scene/gameplaymodes/LoadExampleGameMode.java
  • [ ] scene/gameplaymodes/ModifyGameMode.java
  • [ ] scene/gameplaymodes/MoveGameMode.java
  • [ ] scene/gameplaymodes/PlayGameMode.java
  • [ ] scene/gameplaymodes/SaveGameMode.java
  • [ ] scene/gameplaymodes/TestGameMode.java
  • [ ] ui/Anchor.java
  • [ ] ui/Button.java
  • [ ] ui/List.java
  • [ ] ui/Notifications.java
  • [ ] ui/NumberInputField.java
  • [ ] ui/ScrollBarHorizontal.java
  • [ ] ui/ScrollBarVertical.java
  • [ ] ui/Slider.java
  • [ ] ui/Tab.java
  • [ ] ui/TextInputField.java
  • [ ] windows/ImportLevelWindow.java
  • [ ] windows/LoadLevelWindow.java
  • [ ] windows/SaveLevelWindow.java

danmigdev avatar Jul 12 '22 18:07 danmigdev

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

micycle1 avatar Jul 13 '22 08:07 micycle1

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.

danmigdev avatar Jul 13 '22 09:07 danmigdev

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

calfaand avatar Nov 03 '22 08:11 calfaand

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.

danmigdev avatar Nov 03 '22 19:11 danmigdev