People who inject drugs (PWID) with unsafe injection practices have substantial risk for HIV and hepatitis C virus (HCV) infections. We describe frequency of, and factors associated with, HIV and HCV testing during clinical encounters with PWID. Inpatient and Emergency Department clinical encounters at an Atlanta hospital were abstracted from medical records spanning January 2013–December 2018. We estimated frequency of HIV and HCV testing during injection drug use (IDU)‐related encounters among PWID without previous diagnoses. We assessed associations between patient factors and testing using generalized estimating equations models. HIV testing occurred in 39.3% and HCV testing occurred in 17.1% of eligible IDU‐related encounters. Testing was more likely in IDU‐related encounters during 2017–2018 than in encounters during 2013–2014; (HIV, AOR = 2.14, 95% CI, 1.32–3.49, p < .01). Testing was less likely among Black/African American patients compared to White patients (adjusted odds ratio [AOR]: HIV, AOR = 0.48, 95% confidence interval [CI], 0.33–0.72, p < .01); HCV, AOR = 0.41, 95% CI, 0.24–0.70, p < .01). This difference may be attributable to recent testing among Black patients in non‐IDU related encounters. HIV and HCV testing improved over time; however, missed opportunities for testing still existed. Strategies should aim to improve equitable HIV and HCV testing among PWID.