Both sides previous revision
Previous revision
Next revision
|
Previous revision
|
hekate:heart_overview [2010/03/04 11:00] esimon |
hekate:heart_overview [2019/06/27 15:49] (current) |
To download or check examples of using these libraries check [[HeaRT HowTo]]. | To download or check examples of using these libraries check [[HeaRT HowTo]]. |
===== Automatic Tests ===== | ===== Automatic Tests ===== |
A simple mechanism for testing HeaRT was implemented. It is a bash script called //test.sh// located in //tests// directory. The script takes as a parameter a name of the file with testing data, and produces information about errors on the screen. More detailed information are stored in //log.txt// file automatically created by the script. | A simple mechanism for testing HeaRT was implemented. It is a bash script called //test.sh// located in //tests// directory. (It can be downloaded also from here: {{:hekate:test.txt|test.sh}}) The script takes as a parameter a name of the file with testing data, and produces information about errors on the screen. More detailed information are stored in //log.txt// file automatically created by the script. |
| |
Example use of the script looks as follow:<code>./test.sh thermostat_test.pl</code> | Example use of the script looks as follow:<code>./test.sh thermostat_test.pl</code> |
| |
| |
The log file contains the full trajectory of the system: | The log file contains the full trajectory of the system (see {{:hekate:log.txt|example logfile}}). |
| |
| ==== How to create a test file === |
| - A test file is a HMR file prepared for testing script. |
| - A HMR file that should be a test file has to have two following lines at the begining of the file:<code>:- ensure_loaded('../heart.pl'). |
| :- ensure_loaded('test-predicates.pl').</code> The test-predicates file can be downloaded from here: {{:hekate:test-predicates.pl|}} |
| - Special sets of states have to be added to the file. The state that is an input file have to be called **initX**, where X is some number. The state that describes the expected output should be called **evalX**, where X is a number that binds **init** state with **eval** state. Example of the testing states are shown below: |
<code> | <code> |
THERMOSTATGDI | xstat init2: [day, 1]. |
State "init1": | xstat init2: [hour, 12]. |
[day, mon],[hour, 12],[month, 4], | xstat init2: [month, 4]. |
[dt, ms, th, os] | |
| |
| xstat eval2: [day, 1]. |
State "current": | xstat eval2: [hour, 12]. |
[day, mon],[hour, 12],[month, 4],[today, workday],[season, spring],[operation, bizhrs],[thermostat_settings, 20], | xstat eval2: [month, 4]. |
TDI | xstat eval2: [season, spring]. |
State "init1": | xstat eval2: [operation, bizhrs]. |
[day, mon],[hour, 12],[month, 4], | xstat eval2: [today,workday]. |
| xstat eval2: [thermostat_settings, 20]. |
| </code> It means that for the input state init2, we expect output state eval2. |
State "current": | |
[day, mon],[hour, 12],[month, 4],[season, spring],[today, workday],[operation, bizhrs],[thermostat_settings, 20], | |
DDI | |
State "init1": | |
[day, mon],[hour, 12],[month, 4], | |
| |
| |
State "current": | |
[day, mon],[hour, 12],[month, 4],[season, spring],[today, workday],[operation, bizhrs],[thermostat_settings, 20], | |
GDI | |
State "init2": | |
[day, 1],[hour, 12],[month, 4], | |
[dt, ms, th, os] | |
| |
| |
State "current": | |
[day, 1],[hour, 12],[month, 4],[today, workday],[season, spring],[operation, bizhrs],[thermostat_settings, 20], | |
TDI | |
State "init2": | |
[day, 1],[hour, 12],[month, 4], | |
| |
| |
State "current": | |
[day, 1],[hour, 12],[month, 4],[season, spring],[today, workday],[operation, bizhrs],[thermostat_settings, 20], | |
DDI | |
State "init2": | |
[day, 1],[hour, 12],[month, 4], | |
| |
| |
State "current": | |
[day, 1],[hour, 12],[month, 4],[season, spring],[today, workday],[operation, bizhrs],[thermostat_settings, 20], | |
GDI | |
State "init3": | |
[day, sun],[hour, 19],[month, 1], | |
[dt, ms, th, os] | |
| |
| |
State "current": | |
[day, sun],[hour, 19],[month, 1],[today, weekend],[season, winter],[operation, nbizhrs],[thermostat_settings, 14], | |
TDI | |
State "init3": | |
[day, sun],[hour, 19],[month, 1], | |
| |
| |
State "current": | |
[day, sun],[hour, 19],[month, 1],[season, winter],[today, weekend],[operation, nbizhrs],[thermostat_settings, 14], | |
DDI | |
State "init3": | |
[day, sun],[hour, 19],[month, 1], | |
| |
| |
State "current": | |
[day, sun],[hour, 19],[month, 1],[season, winter],[today, weekend],[operation, nbizhrs],[thermostat_settings, 14], | |
GDI | |
State "init4": | |
[day, wed],[hour, 3],[month, 7], | |
[dt, ms, th, os] | |
| |
State "current": | |
[day, wed],[hour, 3],[month, 7],[today, workday],[season, summer],[operation, nbizhrs],[thermostat_settings, 27], | |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
ERROR: Produced state is different that expected, for states init4 and eval4 | |
ERROR: Produced: [[day, wed], [hour, 3], [month, 7], [today, workday], [season, summer], [operation, nbizhrs], [thermostat_settings, 27]] | |
ERROR: Expected: [[day, mon], [hour, 3], [month, 7], [season, summer], [operation, nbizhrs], [today, workday], [thermostat_settings, 27]] | |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
Done | |
</code> | |
| |
| |