Game
Learn Functional Programming
5 years ago

https://www.youtube.com/watch?v=i3K4i9n1dzg

Article: Keeping LFP Stable with Unit Testing


YouTube
https://www.youtube.com/watch?v=i3K4i9n1dzg
youtube.com

Sometimes the logic in LFP gets a little complicated. Updating one part of the code could break another part of the code.

For example, when I added tokens that can’t be edited by the player, I had to make it so those tokens couldn’t be deleted by the player.

unit_testing_delete_before.png

However, this made it so when you pressed “Evaluate”, which deletes any tokens it evaluates so it can show the result, any uneditable tokens wouldn’t be deleted and the game would get very confused.

unit_testing_delete_after_wrong.png

To make sure new changes don’t break old features, it’s a good idea to retest everything every time you make a change. This is called regression testing.

Normally, this is really annoying to do, but it's very easy with Unit Testing. A unit test has three basic steps:

1) check the current state

2) run some function or feature

3) check the state again to make sure what you expected to happen actually happened

In the example above, I had a unit test that compares how many tokens there are before and after you delete a token. If something went wrong with deleting the token, the automated test can report that the number of tokens isn’t matching what it expects.

This means whenever you add a feature, you’re actually adding both a feature and a test for that feature.

This might sound like a pain, but once you write the test once, you can retest it as many times as you need. Every time you add one feature and one test for that feature, you can then run every test for every feature in your game. If every test passes, you can be confident your new feature didn’t break anything.

If you’re using Godot. I highly recommend Gut for unit tests. This tutorial shows you how to set it up. It's made working on LFP a lot easier for me!



0 comments

Loading...

Next up

🍒Did you like the game? A demo is available for free on Steam.

✌️ Thanks for playing IndieGameiacs!

⚙️ Free Demo: http://bit.ly/UniDuni

📺 Full Video: https://youtu.be/5qEbVXg7GaQ

#steam #uniduni #clops #screenshotsaturday

Just a Pico sprite

Update 2.627

New challenges & new effects!

Hi everyone! I started to create some environment props for my new video game, here is a cozy house in the forest. I'm planning to switch from Unity to Unreal... Let's see what new challenges I have to face. Made in Blender and Substance Painter.

We're glad to announce that Baby Dino Adventures 🦖 is now available in Early Access here on GameJolt! Link: https://gamejolt.com/games/babydinoadventures/508121 Walk, run, and jump as a baby t-rex in this cute platformer Free demo available #IndieGame | #GameDev | #PixelArt

Let me introduce you to the new Mech line: Gendai Spec. Those are Mech that specializes in surprise attacks, covered operations, and stealth. They are equipped with melee weapons but one of Gendai's frames supports sniper rifles.

Only true badasses may pass! #conceptart #art #gamedesign

A sneak peek at the new OST, can you guess what this song will be used for? 🤔

Annie of the stars

Ladies & gentlemen.. The Blender logo factory! I had a ton of un making this animation. I'll be making a short tutorial on picking up/dropping object in Blender for animations next week! What do you think?