Tip:
Highlight text to annotate it
X
Hi, I'm Ethan Fremen, CTO of eye3ware. In this video I'm going to show you a compelling
reason to use TestStar.
One of our goals with TestStar is to allow Unity developers to adopt a "Test-Driven development"
style. What this means for you is being able to catch more bugs during development, before
your project lands in the hands of the first tester.
Right now TestStar provides you a "test suite" approach that gives you something like unit
tests for your game. You create test scenes that automatically test certain aspects of
your game. Your developers and designers can run these tests before committing new code
or art to make sure the new functionality doesn't break anything.
This is one such test run test run, testing that this scene is set up properly and that
some in-game behaviours are working.
TestStar ensures that all tests are run independently; the scene is re-started for each test and
individual test methods of your script are run to completion before the next one is started.
Let's examine one of those tests. The "game" we're testing is the "Lerpz 2D" demo, and
all these tests are included in the demo you receive when you buy TestStar.
What we're testing here is that when the character falls from a platform they are reincarnated
at the spawn point.
We used a copy of the game scene to create this test. The only thing we've added to this
test is a gameObject positioned such that the Lerpz character will fall to its doom.
Let's take a look at the test script.
It was really important to us to build a test framework that never breaks your prefabs,
so that you can be sure you're always testing the prefabs you use in actual game scenes.
However, sometimes you need to attach a script to a prefab in order to test a certain behaviour.
We have to do that in this test, because it is the character who receives a message from
the deathZone. By adding a little mono behaviour to the character on SetUp, we can be notified
when the Lerpz dies without changing the character prefab.
One of the cool things we offer is control over timing of your test runs so that you
can test behaviour that is based on physics. With "WaitForSeconds", your test method is
not called again until that time has passed.
Asserts are the heart of any test framework, and TestStar uses NUnit's expressive framework
to allow you to make declarations about your code in extremely readable form. In this assert
we are declaring that the position of the character must be within .5 of the spawn point.
Now let's look at another TestStar feature that really makes it great for testing different
scenarios: "Ghosting".
In any game, you have behaviour that is only true when a certain number of events or preconditions
are true. If you had to make a scene for every permutation, it would be a pain. While TestStar
provides support for creating these scenarios in code, we also make it easy for you to build
alternate scenarios by hand.
Here's a simple example. We have a platform that falls whenever three crates are on it.
We want to test that it doesn't fall when it has less than three crates, and does fall
when there are three crates.
So we set up the first scenario: a crate falls and the platform does not. Great, but now
we want to test with two crates, and we don't want the first crate to get in the way.
To achieve this, we "Ghost" the first crate. This makes the crate "disappear" from the
scene, but it reappears for this test.
Ghosted objects may be inspected if you need to tweak their parameters, or unghosted to
make it reappear.
Now for the two-crate example. We add two crates, and verify that the test passes.
Then we select the two crates, and ghost them.
Now we can run both tests.
The first crate only appears in the first test
and the two crates only appear in the second.
And now for the grand finale: this time we add three crates, and verify that the platform
indeed falls.
We ghost the three crates, and run all the tests.
In each case, the ghost feature makes the objects we need for our test available for
that test, and none other.
That wraps up our quick illustration of how TestStar lets you build your game with a test
driven development methodology.
You can buy our test framework on the Unity asset store. If you'd like to license it for
your whole team, contact us and we can work out a group discount.
Please feel free to contact us with any questions you may have. If you'd like to speak with
me directly, you can email me, contact me on irc, or contact me via Skype or aim.
Thanks for watching, and I hope your game is BugFree(™)!