This is an old revision of the document!
hierarchy typically looks like:
Unit testing (atomic level) - individual functions/methods. (Module testing often gets lumped into either “unit testing” (for simple modules) or “component testing” (for complex modules))
Component testing - groups of related units working together
Integration testing - multiple components interacting
System testing - entire application
OPTIONS
Classic1: Unittest / **pytest** libraries
Modern1: PyATS
Assertions
assert interface.status == "up"
Markers
Definition: Annotations to add metadata to test functions or classes.
Usage: Used to categorize, skip, or parametrize tests.
Examples:
@pytest.mark.sanity
(categorization)
@pytest.mark.skip(reason="Not implemented")
(skipping)
pyATS-specific:
@aetest.loop
,
@aetest.setup
,
@aetest.cleanup
Purpose: Control test behavior, grouping, and execution.
Fixtures
@pytest.fixture
def test_device():
device = connect_to_device("router1")
yield device
device.disconnect()
Parametrization
@pytest.mark.parametrize("ip", ["8.8.8.8", "1.1.1.1"])
def test_ping(ip):
assert ping(ip)
Other Relevant Concepts
Testcase/Testscript:
Sections:
Special methods within a testcase, such as
setup
,
test
, and
cleanup
.
Testbed:
Loggers:
Used for reporting test steps and results (
log
object).
aetest:
Examples