Author:halw

Date:2009-02-04T22:23:00.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@179 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
halw
2009-02-04 22:23:00 +00:00
parent b884881b44
commit f14187925f

View File

@@ -1,5 +1,4 @@
[[Property:title|Create and run a manual test]] [[Property:title|Create a manual test]]
[[Property:link_title|Create a manual test]]
[[Property:weight|2]] [[Property:weight|2]]
[[Property:uuid|e78f25e3-ed3a-f8fa-e71d-28a4dda1825f]] [[Property:uuid|e78f25e3-ed3a-f8fa-e71d-28a4dda1825f]]
{{underconstruction}} {{underconstruction}}
@@ -97,9 +96,73 @@ To begin the process of creating a new test, click the Create New Tests button o
[[Image:create new tests]] [[Image:create new tests]]
If this is the first time you've used the testing tool for this project, it is likely that you will be presented with a dialog box asking if you want to add the testing library classes to your project and recompile. This will launch the New Eiffel Test Wizard which guides you through the test creation process.
If this is the first time you've used the testing tool for this project, it is likely that you will be presented with a dialog box asking if you want to add the testing library classes to your project and recompile:
[[Image:add testing libraries dialog]] [[Image:add testing libraries dialog]]
You want EiffelStudio to do this before launching the wizard so, click "Yes". In a moment your system will have recompiled with the testing library classes available. Remember that you won't need to interact much with the testing classes, but the Eiffel Testing Framework uses them, so they need to be available. As long as the testing classes stay available, you should not see this dialog again for the current project.
==The New Eiffel Test Wizard==
After the compile completes, then the first pane of the New Eiffel Test Wizard appears. It should look like this:
[[Image:New test wizard screen 01 01]]
As you can see, there is a radio button for each of the three types of tests that were discussed in [[Testing: Background and basics]]. The buttons for '''Manual''' and '''Synthesized''' tests are enabled. The button for '''Extracted''' tests is not sensitive because the extraction of tests is only valid during the time in which a system is actually running. That's okay, we were going to choose '''Manual''' anyway.
If we select '''Manual''' and click '''Next''', then second pane of the wizard appears:
[[Image:New test wizard screen 02M 01]]
We will use this wizard pane to name our test class and let the Eiffel Testing Framework know where we want the test class to reside. You can give a test class any name you wish, as long as it doesn't conflict with another class name in your system. If you try to type in a class name that already exists, the wizard will let you know right away by changing the text color to red. There is a convention that has arisen around test class names. If possible make the test class name the name of the target class, prefixed with <code>TEST_</code>. So in our case, we want to build a test against a feature of the <code>BANK_ACCOUNT</code> class, so we will name our test class <code>TEST_BANK_ACCOUNT</code>.
Now, for the question of where the tests should be kept. Again, you can keep them anywhere you wish, but there are some advantages to keeping the test classes in a '''test cluster''' separate from your target classes. For example, it will be easier for you to deliver your application or library classes if the testing classes are mixed it. A '''test cluster''' is just a cluster of classes that EiffelStudio and the Eiffel Testing Framework expect to contain test classes. So we want to create a new testing cluster as a subcluster of the cluster in which the classes <code>APPLICATION</code> and <code>BANK_ACCOUNT</code> reside.
Notice the '''New cluster''' button ( [[Image:16x16--new-cluster-icon]] ) on the wizard pane above. We click that button to add a new test cluster. The '''Add Cluster''' dialog box appears:
[[Image:New test wizard add cluster 01]]
As with test class names, there is an emerging convention for the name of a test cluster: <code>tests</code> . So we will name our test cluster <code>tests</code> and make it a subcluster to our root cluster <code>bank_account</code>. Notice that there is a '''test cluster''' check box on the dialog. It is checked and disabled, so at this point in the wizard you would always create a test cluster. Once the test cluster is created, we're back to the second wizard pane which now looks like this:
[[Image:New test wizard screen 02M 02]]
We're ready to click '''Next''', but before we do, let's look at the check boxes on this wizard pane. The two check boxes labeled '''Redefine `on_prepare'''' and '''Redefine `on_clean'''' have to do with the way that tests are run.
The Eiffel Testing Framework runs each test as a three step process:
# Preparation
# Execution
# Clean up
There are features in class <code>EQA_TEST_SET</code> named <code>prepare</code> and <code>clean</code> which accomplish steps 1 and 3 above. These features are <code>frozen</code>, therefore you cannot redefine them in a test class (i.e., a descendant of <code>EQA_TEST_SET</code>) However the class does provide features that can be redefined so that you can include custom behavior before and/or after the execution of a test. These features are <code>on_prepare</code> and <code>on_clean</code>. So if you check one of these boxes, then the test class that is built for you will include a redefined feature ready for you to implement. In this simple example, we'll leave both boxes unchecked.
{{note|The check box labeled '''System level test''' is displayed here as not sensitive. This box is reserved for future system level testing capability in the Eiffel Testing Framework, so for versions including 6.4, you can ignore it. }}
After clicking '''Next''', we see the third pane of the wizard. In this pane, we will describe our manual test routine. It looks like this:
[[Image:New test wizard screen 03M 01]]
Here we will name our test. Let's say that we plan to write this test against the feature <code>{BANK_ACCOUNT}.deposit</code>. Like the naming convention for test classes, we'll give this test the name <code>test_deposit_01</code>. The prefix <code>test_</code> before the feature name it will test, and the suffix <code>_01</code> so that we have a framework for adding more tests against <code>deposit</code>. Again, you can choose any naming scheme that makes sense to you. You may want to try to describe the test in its name. For example, <code>test_deposit_very_large_amount</code>.
==About Tags==
The other thing that can be done on this pane is to associate our test with any Eiffel Testing Framework '''tags''' that we feel are appropriate.
'''Tags''' are simply hierarchical names that can be associated with a test to help manage, maintain, execute, and monitor its results. It is quite likely that your system may eventually accumulate a great number of tests. And you may want only to execute some selected portion of those tests at any particular time. '''Tags''' help you do that