I can't understand why I have so many methods to run before or after a test function.
You don't have to implement all these methods. FB generated all these stubs for you, but you might as well leave them out.
That said, you can have more than one test function inside a test class. You usually test every public function of a class. You may even have multiple tests per function, using different sets of corner-case arguments.
e.g. in your example you only test the constructor, but you might have a test for:
car.turnLeft(32)
(in degrees)- or see what happens when
car.turnLeft(0)
- or
car.turnLeft(190)
(you're getting on the terrain ofcar.turnRight
here) - or
car.turnLeft(-12)
(negative turnLeft?)
The before/after methods can be used to write some code that you want executed before/after every test in the class, so that you don't have to repeat this in each test function.
these tests test each class individualy
It is a unit test isn't it?
Can I test my whole application once by instanciating the main class?
That's not what unit tests are for: they only test classes. There are other kinds of testing tools to test (parts of) applications:
- behavioural test tools: in which you write scenario's that contain a typical execution sequences and assert that the outcome of such sequences is correct. I believe Cucumber can test Flex apps in this way (but not entirely sure)
- UI test tools: in which you record scenario's of users clicking around in your application. These scenario's can then be played back to test whether the application keeps running as expected. FlexMonkey is one such solution for Flex apps, but it seems the owners have changed direction with the product.