This function is designed to test other custom functions using the extreme programming approach and, most probably, a custom function test unit (if you haven't read the referenced post, you'd better start with it). The function works fairly well both as a specification and as a test engine.
Technorati tags: FileMaker, FileMaker 7, FileMaker 8, custom function, test unit.
The function is very simple:
Assert Equals( actual value, expected value )
TAB and CR are simple “constant” custom functions returning a tab character or a carriage return; see NULL, TAB, CR, SPACE. You may just replace them with tabs and carriage returns themselves or any other character you prefer.
If an assertion is true, the function doesn't return anything; no news are good news. If an assertion is false, the function displays both expected and actual values. If you need to test several assertions, you can join several functions with an &
Benefits of using this function
As I said, the function looks quite good as a specification. For example, if you're going to develop a function to calculate Roman numerals and write test before code, you might end up with something like this:
which is fairly readable. If your custom function requires complex data, you can use the Let() statement to add some “test fixture”:
which is also very clear.
Test unit tests
Installation:
A simple test of functionality.
Comments