Testing Strategies
From Erlang Community
| Revision as of 07:12, 3 September 2006 (edit) Rvg (Talk | contribs) (Create page) ← Previous diff |
Current revision (16:38, 2 July 2007) (edit) (undo) Karl (Talk | contribs) m (Tagged as Article) |
||
| (3 intermediate revisions not shown.) | |||
| Line 1: | Line 1: | ||
| + | [[Category:Testing]] | ||
| + | [[Category:Articles]] | ||
| ==Authors== | ==Authors== | ||
| [[User:Rvg|Rudolph van Graan]] | [[User:Rvg|Rudolph van Graan]] | ||
| - | |||
| This page is under construction it needs to be filled out. | This page is under construction it needs to be filled out. | ||
| - | |||
| ==How to deal with test data== | ==How to deal with test data== | ||
| ===Mnesia=== | ===Mnesia=== | ||
| Line 29: | Line 29: | ||
| * Before running a set of suites or a test, restore this database | * Before running a set of suites or a test, restore this database | ||
| ==Modules without side-effects== | ==Modules without side-effects== | ||
| + | This is the simplest case. An example of the test specification is: | ||
| + | <code> | ||
| + | [test_1, | ||
| + | test_2] | ||
| + | </code> | ||
| ==Modules with side-effects== | ==Modules with side-effects== | ||
| In this scenario you need to make sure you clean up after running the test. Examples where you need this: | In this scenario you need to make sure you clean up after running the test. Examples where you need this: | ||
| Line 38: | Line 43: | ||
| stop_ets_owner_process}] | stop_ets_owner_process}] | ||
| </code> | </code> | ||
| - | The test case ''start_ets_owner_process'' would spawn | + | The test case ''start_ets_owner_process'' would spawn a process that owns the ets table. It stores the PID of the process in the [[Test Configuration]] returned by start_ets_owner_process. |
| - | + | ===Notes=== | |
| - | == | + | # Don't use spawn_link(...) as the process would terminate as soon as the system exits the test case |
| - | + | ||
| ==Running variations of tests== | ==Running variations of tests== | ||
| An example where you need to run variations of tests is when your system supports multiple versions of the same protocol. | An example where you need to run variations of tests is when your system supports multiple versions of the same protocol. | ||
Current revision
Contents |
[edit] Authors
Rudolph van Graan This page is under construction it needs to be filled out.
[edit] How to deal with test data
[edit] Mnesia
- Before starting Mnesia, make sure that all previous test schemas are cleaned out
- Create a new Mnesia schema
- Install the Mnesia tables
- Run the code that puts the basic data in place
- Insert the minimum number of rows
- Try to use unique keys for each test, so they don't interfere with each other
- Run the tests
- Leave the database intact so you can perform analysis after a failure
[edit] Relational Databases where your system controls the data
This is basically the same as the mnesia test case.
- To get your initial data into the database:
- Recreate the database schema or
- Clear all the tables that you require
- Insert test data
- Run the tests
- Leave the database for later analysis
[edit] Relational Databases where your system doesn't control the data
This is a difficult problem to solve. Especially where the database can potentially change.
Try the following
- Copy the database onto a clean machine and make a backup of its state, possibly deleting a lot of the records to get its size as small as possible
- Before running a set of suites or a test, restore this database
[edit] Modules without side-effects
This is the simplest case. An example of the test specification is:
[test_1, test_2] |
[edit] Modules with side-effects
In this scenario you need to make sure you clean up after running the test. Examples where you need this:
[edit] Testing functions in ETS
[{conf,
start_ets_owner_process,[test_1,
test_2],
stop_ets_owner_process}]
|
The test case start_ets_owner_process would spawn a process that owns the ets table. It stores the PID of the process in the Test Configuration returned by start_ets_owner_process.
[edit] Notes
- Don't use spawn_link(...) as the process would terminate as soon as the system exits the test case
[edit] Running variations of tests
An example where you need to run variations of tests is when your system supports multiple versions of the same protocol. Here is a configuration case illuastrating it:
[
{conf,
connect_version_1,[test_function_1, % Function 1 and 2 are common to both protocols
test_function_2,
test_function_3_fails % There should be an error here as this function doesn't exist in V1
],
disconnect_version_1},
{conf,
connect_version_2,[test_function_1,
test_function_2,
test_function_3 % Function 3 was added, so it must succeed
],
disconnect_version_2}
]
|

Digg It
Del.icio.us
Reddit
Facebook
Stumble Upon
Technorati

