def test_eval_loop_config(tmp_path):
    """When either eval step or eval data is missing."""
    trainer = Trainer(default_root_dir=tmp_path, max_epochs=1)

    # has test data but no val step
    model = BoringModel()
    model.validation_step = None
    with pytest.raises(MisconfigurationException, match=r"No `validation_step\(\)` method defined"):
        trainer.validate(model)

    # has test data but no test step
    model = BoringModel()
    model.test_step = None
    with pytest.raises(MisconfigurationException, match=r"No `test_step\(\)` method defined"):
        trainer.test(model)

    # has predict data but no predict_step
    model = BoringModel()
    model.predict_step = None
    with pytest.raises(MisconfigurationException, match=r"`predict_step` cannot be None."):
        trainer.predict(model)

    # has predict data but no forward
    model = BoringModel()
    model.forward = None
    with pytest.raises(MisconfigurationException, match=r"requires `forward` method to run."):
        trainer.predict(model)
When either eval step or eval data is missing.
tests/tests_pytorch/trainer/test_config_validator.py