def test_raises_error_on_missing_fields() -> None:
        """Test that an error is raised when required fields are missing in strict mode."""
        metric_cls = create_anomalib_metric(DummyMetric)

        metric = metric_cls(fields=["non_existent_field"])
        batch = ImageBatch(image=torch.rand(4, 3, 10, 10))  # batch without field
        with pytest.raises(ValueError, match="instance is missing required field"):
            metric.update(batch)
        assert metric._update_count == 0  # noqa: SLF001
        assert metric.update_called is False
Test that an error is raised when required fields are missing in strict mode.
tests/unit/metrics/test_anomalib_metric.py