Cabal-Syndicate / randora_framework

Framework for the Randora Game Engine
Other
3 stars 1 forks source link

Create Unit Tests for RNDOwned #15

Open Master-Foo opened 9 years ago

Master-Foo commented 9 years ago

Do this after the mixin issue...

Look at the RNDObject project for examples on how to do this.

First of all, let me know what your experience in unit testing is. Have you done it before?

Basically, there should be a tests folder with a number of files named after the property / method / event that needs to be tested. If not, follow the examples in RNDObject, you'll get the idea. Ideally, everything should have a few tests.

The general idea is to create tests which:

  1. Test the default behaviour of a variable / method / class.
  2. Test to make sure the variable / method / class behaves as expected when you change values / use methods / etc.
  3. Try to enter "bogus data" into variables / methods to see if they fail properly. For instance, let's say we have a string and it is supposed to have a max length of 5 characters. You'd make a test that alters that string to have 6 characters. Then you'd check the length. The string should only have 5 characters even though you entered 6. (That's just an example, there isn't any such use case in the actual code).

You should try to be as surgical as possible. So, if there is a property Foo you should try to isolate that and test it without other Properties in that class. An example is in randora.engine.object.properties.tests.name You'll notice that I made a Name class and mixied in the property Name so as to isolate it from other Properties and Events.

Create as many of these tests as your patience can manage.

Master-Foo commented 9 years ago

Oh, BTW...

You can run tests like this:

bash $ dub run --build=unittest



It is ready to go, but if you want to see, the configuration for this is in dub.json