image classification with training set with 4 classes and test set with 3 classes
In principle there's nothing wrong with that, since every instance in the test set is predicted individually. You will have a 4 x 3 confusion matrix, because the model might predict some false positives on the fourth class. Of course you won't be able to know if the model can correctly identify a true instance from the missing class.

It depends what is the goal: 


If the model is meant to be able to predict any of the 4 classes, then it should be trained on the 4 classes and it would be preferable to also test it on the 4 classes, but testing it only on 3 should already gives a good indication of its performance.
If the model only needs to predict 3 classes ever, then the instances of the 4th class should be removed from the training set since they just make things more complex.