In short, yes, they can. However, a crap diet and mediocre training program will certainly decrease the effectiveness of your testosterone booster. And a great training program and a solid diet can both help you build muscle and boost testosterone.
Certified strength coach Parker Hyde shows how to maximize your levels with your gym work in the article "How to Naturally Boost Testosterone Release with Exercise." In short, loading (or "intensity"), overall volume, exercise choice, and even exercise order can have an impact.
Likewise, the amino acids in a protein-rich diet play a big role in both testosterone and muscle growth. As Chris Lockwood, Ph.D., explains, "When combined with training, which increases the sensitivity of androgen receptors, and the consumption of essential amino acids necessary to support protein synthesis, the effects of testosterone on muscle and performance is significantly amplified."[3,4]
So before you take a single serving of your test booster, make sure you've got yourself set up for success. Exercise consistently with a well-designed muscle-building program, and make sure you are taking in adequate protein and overall calories based on your body weight, goals, and activity level.
Focus on eating right and training hard, and your testosterone booster will be worth more!