Test Fixture Code Block
- Sep 10, 2013
What is a test fixture?
The test fixture is used to write code that will validate the kata solution.
The entire set of code in this block acts as a single test case. To validate solution code
you can use the Test.expect(passed_boolean, optional_message) method. More advanced testing methods are also available.
Click here to view the documentation for the test framework.
Validating the solution:
Once your solution and fixtures have code you can click "validate solution"
to check if your code validates. Generally only reference/syntax errors will be descriptive.
Failed test expectations will have generic messages unless you provide a custom message.
These are the same errors that others will see when they are solving your kata.
Success/failure information will also be written to the output area. If you choose to use a the spec style methods (describe/it) then the output will display the information described in these methods.
Previewing the challenge & custom Test.expect messages:
Un-published kata's have the ability to preview solving them. This action is available in the top
right of the action bar. It is recommended that you try to take the challenge yourself and see
what types of common errors may come up during the process. This is a useful way of discovering
ways in which you can provide Test.expect methods with custom messages to help guide others.
These custom messages can be much more useful then the standard runtime errors that
would otherwise be shown.
method then you might test for it using Test.expect(Foo.get, "Foo.get method is not defined").
This error would be much more useful then what the user would otherwise see.