Intro To The VFPUnit Workbench. Please follow instructions verbatim, there is a lot of behavior packed into small examples. | |||
You may copy and paste or Highlight and drag Sample Code into VFPUnit | |||
Lets kick the tires and see how this thing works. Open a new experiment. Do this by pressing the 'Experiment' button on the 'Suites of Experiments' form. - If an experiment was already selected in the list box, it will be opened. -then press new on the experiment form. - If no experiment was selected, a new experiment will be opened. Call it 'A' (or whatever you want) [the field next to the experiment button] In the Test Code editbox, type in the following line, and then Press the 'Run' Button. Note: you do -Not- have to save the experiment before running it!. | ||||
WAIT WIND 'Hello' | ||||
|
| ||||
This simple example points out a very important point, that is, that how this workbench operates is entirely dependant upon what code you put in the test code edit box. The Test Code entry area is where 90% of your time will be spent, creating objects, writing tests, maybe some debugging, or just general mucking around. I hope the prospect of typing in this puny edit box disappoints you, It did me. We've come to expect syntax help, syntax coloring, formatting options, undo, intellisense, yada yada yada, .., when we are writing code. So, I added an alternate way of editing test code. By pressing the 'Test Code' button on the experiment form, a copy of this editbox text is placed in a temporary file, and opened in a separate window that lets us have all those goodies. The important part to note here, is that the 'Apply' button on this editing window saves the temporary file you are working on, back to the edit region of the experiment form. -it does not save the whole experiment. (we have yet to save the experiment.., don't bother to yet) If you haven't pressed the Test Code edit button yet, do so now. You should see a window titled 'Sample', and a region titled 'Testing Code'. | ||||
lnX = _screen | ||||
and then type a '.', | ||||
you should see intellisense activate the drop down list of properties and methods for the _screen object. Choose formCount from the list for now. Complete so that the code is: | ||||
*- Note: there is an INTENTIONAL error in the following line!!! lnX = _screen.formCount +" Forms Active" && number+string = error WAIT WIND NOWAIT "There Are " +ALLTRIM(STR(lnX)) | ||||
|
| ||||
Because we cannot concatenate character strings onto numbers, a 'Test Results' window should appear to tell you that there was a SAMPLEING FAILURE: Operator/operand type mismatch. This also 'cascaded' into the 'SAMPLEING FAILURE: Variable 'LNX' is not found.' error | ||||
lnX = _screen.formCount WAIT WINDOW NOWAIT "There Are " +ALLTRIM(STR(lnX)) +" Forms Active" | ||||
Press the 'Apply and Run' button. | ||||
If the code is correct, a wait window should have appeared in the upper right corner,
But, -Nothing happened in the 'Test Results' window!
Nothing -should- have happened, for there where no errors.
After a short time, It will become natural to expect to see results appearing in that window,
and I often catch myself looking for results when there should be none.
Press 'Clear' or 'Reset' of the Test Results often to avoid misinterpreting the results
when doing interactive coding. {just a hint}.
| |||
Onward..,
TEST and MEASURE. Are keywords whose purpose is to store a Result,
which is then displayed in the 'Test Results' window.
These two Keywords are identical in every way. I just couldn't decide which one is more appropriate...
I'm favoring TEST, for it is shorter, and easier to type, while MEASURE is more indicative of it's function.
From now on I'll use the keyword TEST, you can use either one interchangeably.
{this may be a moot point when you examine this, i may have made up my mind!}
TEST acts like a public function, that accepts up to 2 arguments (parameters).
TEST(lSuccess, [cFailMessage])
1) lSuccess a Boolean value. often is an expression, whose result is a Boolean.
2) cFailMessage an optional message. often an expression that states expected vs. actual results.
Change the code to read:
| ||||
lnX = _screen.formCount WAIT WINDOW NOWAIT "There Are " +ALLTRIM(STR(lnX)) +" Forms Active" TEST() | ||||
|
| ||||
a Test Result should have been added that simply states: 'Failed', since the lSuccess defaults to .F.
Exercise the different combinations of calling TEST.
{Purists would scold me for introducing the idea of having multiple Tests in an experiment, see notes for why.}
Enter in the following code.
| |||||
lnX = _screen.formCount WAIT WINDOW NOWAIT "There Are " +ALLTRIM(STR(lnX)) +" Forms Active" TEST() TEST(.T.) TEST(.F., 'Sample Failed cuz I told it to') * be aware when mixing quotes. TEST(.T., 'This Message Is Visible in "Result Details Window" only, for lSuccess was Set to .T.') * Constant KCR is internally defined as CHR(13) TEST(.F., 'Messages Can Span Multiple Lines' +KCR +'By Using The Constant KCR' +KCR +'Open Details Window To See') | |||||
|
| |||||
This seems like a good place to save and start a new experiment. Apply and then close the sample window. On the experiment form, in the field marked 'Suite', type in the word "Tutorial". This will create a 'Suite' named Tutorial, that we can use to organize a set of related experiments. Whenever this field is enabled, you may enter a name for a new Suite. You can always change the assigned Suite of an experiment by pressing the 'Suite' button adjacent to the entry field. Press the 'Save' button on the experiment form. | |||
Hope to have accomplished: seen major pieces of the workbench. how to make and edit test code. control the messages of results. have seen both exception errors and test results. | |||
| Next | Previous | Main |
Generated 03/11/02 01:49:41 PM |