Professors will generally make a new set of problems for their exams. But on occasion, some will take problems from other sources. Questions from problems or variations of the questions often are used on these tests. So if possible, do the homework problems over again. But if you do not have time to work through all of the homework problems, at least study the solutions and work through the ones that you had difficulty with.
Old exams are another source of questions for the tests.
Some professors will distribute sample midterms and it is highly recommended that you work through them. The test problems may not always match the ones on the sample in terms of content, but once in a while, the problems will be nearly identical. Many departments also have exam files that allow you to study and complete previous term exams. A final source for test problems may be non-assigned textbooks. This actually happened in an upper-division Electrical Engineering course.