core.testing¶
One of the challenges of openHAB rule development is verifying that rules are behaving correctly and haven’t broken as the code evolves. This module supports running automated tests within a runtime context. To run tests directly from scripts:
import unittest # standard Python library
from core_mock.testing import run_test
class MyTest(unittest.TestCase):
    def test_something(self):
        "Some test code..."
run_test(MyTest)
This module also defines a rule class, TestRunner. When a switch item is turned on, it will run a testcase and store the test results in a string item.
- 
class core.testing.TestRunner(test_case, trigger_item_name, result_item_name)¶
- Bases: - core_mock.jsr223.scope.SimpleRule- A rule that will run a test case when a switch item is turned on. The results of the test run are placed in a second string item.