diff --git a/tangostationcontrol/requirements.txt b/tangostationcontrol/requirements.txt
index 8d628544905096b9a717719b18bb25293bb0e72d..4788e3c46d40d1ef61cd3e6d1a67ee83a7d5c070 100644
--- a/tangostationcontrol/requirements.txt
+++ b/tangostationcontrol/requirements.txt
@@ -4,6 +4,7 @@
 
 importlib-metadata<2.0.0,>=0.12;python_version<"3.8"
 lofar-station-client@git+https://git.astron.nl/lofar2.0/lofar-station-client@0.9.2
+coverage>=6.0.2 # Apache-2.0
 numpy
 mock
 asyncua >= 0.9.90 # LGPLv3
diff --git a/tangostationcontrol/tangostationcontrol/common/constants.py b/tangostationcontrol/tangostationcontrol/common/constants.py
index a88e7151ae4fa767550167e156e956f3b71527db..fbd4efb05d6b5d77f29ed90cd8e6b5e2f433c79a 100644
--- a/tangostationcontrol/tangostationcontrol/common/constants.py
+++ b/tangostationcontrol/tangostationcontrol/common/constants.py
@@ -1,5 +1,6 @@
 from tangostationcontrol.common.baselines import nr_baselines
 
+DEBUG = True
 
 # number of FPGA processing nodes
 N_pn = 16
diff --git a/tangostationcontrol/tangostationcontrol/devices/lofar_device.py b/tangostationcontrol/tangostationcontrol/devices/lofar_device.py
index 662c3303289549f74495d1179a718bcdaa7ab939..524ea85f026c9e04e446611eeeaa8684bdfc06b4 100644
--- a/tangostationcontrol/tangostationcontrol/devices/lofar_device.py
+++ b/tangostationcontrol/tangostationcontrol/devices/lofar_device.py
@@ -24,9 +24,9 @@ from tango import AttrWriteType, DevState, DebugIt, Attribute, DeviceProxy, Attr
 # Additional import
 from tangostationcontrol import __version__ as version
 from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper
-
 from tangostationcontrol.common.lofar_logging import log_exceptions
 from tangostationcontrol.common.states import DEFAULT_COMMAND_STATES, INITIALISED_STATES
+from tangostationcontrol.common import constants
 from tangostationcontrol.common.type_checking import sequence_not_str
 from tangostationcontrol.devices.device_decorators import only_in_states, fault_on_error
 from tangostationcontrol.toolkit.archiver import Archiver
@@ -199,10 +199,39 @@ class lofar_device(Device, metaclass=DeviceMeta):
             elif not mask[idx]:
                 merge_values[idx] = current_values[idx]
 
+    def store_coverage(self):
+        try:
+            self.cov.stop()
+            self.cov.save()
+            logger.info("Stopped code coverage measurements")
+        except Exception:
+            pass
+    def start_coverage(self):
+        try:
+            import os
+            import atexit
+            import coverage
+
+            self.cov = coverage.Coverage(
+                data_file=os.getcwd() + "/tangostationcontrol/.coverage",
+                data_suffix=True,
+                branch=True,
+                source=os.getcwd() + "/tangostationcontrol/tangostationcontrol"
+            )
+            self.cov.start()
+            logger.info("Started code coverage measurements: %s", os.getcwd())
+
+            atexit.register(self.store_coverage)
+        except Exception as e:
+            logger.warning("Could not configure for code coverage: %s", e)
+
     @log_exceptions()
     def init_device(self):
         """ Instantiates the device in the OFF state. """
 
+        if constants.DEBUG:
+            self.start_coverage()
+
         # NOTE: Will delete_device first, if necessary
         Device.init_device(self)
 
diff --git a/tangostationcontrol/tangostationcontrol/test/base.py b/tangostationcontrol/tangostationcontrol/test/base.py
index 7cf3af7f8becb1f92cde139290394ea540f5d8d6..d3d0955f903f15c812d009d8366a0a77ea4bae14 100644
--- a/tangostationcontrol/tangostationcontrol/test/base.py
+++ b/tangostationcontrol/tangostationcontrol/test/base.py
@@ -16,6 +16,15 @@ import asynctest
 """Setup logging for unit tests"""
 configure_logger(debug=True)
 
+import logging
+logger = logging.getLogger()
+
+
+# def tearDownModule():
+#     import pdb; pdb.set_trace()
+#     logger.fatal("HELLO TEARDOWN?")
+#
+# unittest.addModuleCleanup(tearDownModule)
 
 class BaseTestCase(testscenarios.WithScenarios, unittest.TestCase):
     """Test base class."""
diff --git a/tangostationcontrol/test-requirements.txt b/tangostationcontrol/test-requirements.txt
index 03aa93626787882f5abea3c037d1e324669bc9d8..603cc7d4ca8281b5b23fc2a415c81ba3fb3125e1 100644
--- a/tangostationcontrol/test-requirements.txt
+++ b/tangostationcontrol/test-requirements.txt
@@ -7,7 +7,6 @@ asynctest>=0.13.0 # Apache-2.0
 bandit>=1.6.0 # Apache-2.0
 virtualenv>=20.16.0 # MIT
 build>=0.8.0 # MIT
-coverage>=5.2.0 # Apache-2.0
 doc8>=0.8.0 # Apache-2.0
 flake8>=3.8.0 # MIT
 flake8-bugbear>=22.1.11 # MIT
diff --git a/tangostationcontrol/tox.ini b/tangostationcontrol/tox.ini
index 332d3777fd58491bfe96c270568a12e8d10f5f77..73fe8ba9f9cf0edf3f7a6a802b105127674f57fa 100644
--- a/tangostationcontrol/tox.ini
+++ b/tangostationcontrol/tox.ini
@@ -42,6 +42,10 @@ envdir = {toxworkdir}/testenvpy39
 [testenv:py310]
 envdir = {toxworkdir}/testenvpy310
 
+[testenv:debug]
+basepython=python3.7
+commands = {envpython} -m testtools.run {posargs}
+
 [testenv:integration]
 allowlist_externals = echo
 passenv = TANGO_HOST