If you start losing your motivation at work, it's easy to blame the conditions: low pay, boring tasks, low-quality products (both the ones you are making and the ones you are using) or your boss and colleagues' lack of respect for you. You can moan about this all and yearn for change, and still stay passive and pessimistic. This is the biggest mistake you can make. You can, of course, find another job and hope everything turns out to be better. However, you might find yourself in exactly the same situation again pretty soon.
Dave Thomas said in an interview that "To motivate yourself and keep yourself committed, you need to have pride in what you're doing." I think this is absolutely true. I believe the most important thing you should remember is that you can affect your surroundings. So, instead of finding a perfect workplace, you could try making your current workplace one.
Don't live with broken windows. Finding another job might seem like an easy way out. But choosing the easy way seldom makes one proud. Pride comes from making things change for the better. So if something really gets on your nerves, try to change it instead of escaping it. This could not only make your own life easier, but it might also prove your bosses that you're a valuable asset to your employer.
For example, if your employer doesn't seem to find continuous testing of software important, try introducing the benefits of test-driven development to them. This should help both your conscience and your employer.
Then again, sometimes employers are not willing to spend valuable time training their staff to use new methods. They might rather stick to old habits, however inefficient they may be. In cases like this, you should remember that sometimes pride comes from making big decisions that cause a lot of changes. Like going for that another job.