code: def test_metric(self):
      auto_xgb_reg = AutoXGBRegressor(
          cpus_per_trial=2,
          name="auto_xgb_regressor",
          tree_method="hist",
      )
      data, validation_data = get_data()
      with pytest.raises(RuntimeError) as exeinfo:
          auto_xgb_reg.fit(
              data=data,
              epochs=1,
              validation_data=validation_data,
              metric="logloss",
              search_space=get_xgb_search_space(),
              n_sampling=4,
          )
      assert "metric logloss" in str(exeinfo)
      auto_xgb_reg.fit(
          data=data,
          epochs=1,
          validation_data=validation_data,
          metric="logloss",
          metric_mode="min",
          search_space=get_xgb_search_space(),
          n_sampling=4,
      )
  
file_path: BigDL/python/orca/test/bigdl/orca/automl/xgboost/test_auto_xgb.py
imports: import pytest
  from bigdl.orca.automl.xgboost import AutoXGBRegressor
  import numpy
  from unittest import TestCase
  from bigdl.orca.automl import hp
label_desc: Use image node_id 4 for calling the TestAutoXGBRegressor obj's underlying member method code with example usage: obj.test_metric() without return types