You are absolutely correct that this is an problematic approach. Your testing set should only be used at the last possible stage before deploying a model.
By using your testing set to make modeling decisions you will introduce bias which will favor the observations found in your test set and may not generalize. In an ideal world, your test set would represent the real distribution perfectly, however in practice this is never the case. Thus the suggested approach would result in a model that matches the test set's distribution more closely, but does not generalize to the real distribution.
The correct approach is to separate your data into a
- training set,
- validation set and,
- testing set.
You then set the testing set aside until you have chosen a final model. With the validation set you are very much permitted to do what your professor suggested. You can fit multiple models and then pick the best one, or use all the models together in some bagging structure. Once you are satisfied you can then test against your testing set to see if the selected model generalized well.