Unittest integration¶
The unittest adapter uses inheritance rather than pytest concepts:
from benchcore.core.models import BenchmarkConfig
from benchcore.integrations.unittest import BenchCoreTestCase
class SortingTests(BenchCoreTestCase):
benchmark_config = BenchmarkConfig(rounds=5, iterations=10)
benchmark_name = "sorted-small"
def test_sorted(self) -> None:
result = self.benchmark(sorted, [3, 1, 2])
self.assertEqual(result.value, [1, 2, 3])
One test instance may complete one benchmark. benchmark_reports exposes an
immutable tuple of completed reports. Without benchmark_name, TestCase.id()
becomes the report identity.
Callable failures remain normal unittest errors and produce no partial report.