Background Diagnosis is essential for engagement in care for chronic hepatitis B (CHB) and chronic hepatitis C (CHC), however, many Australians remain undiagnosed, especially for CHB. Primary care represents an important setting for testing, and this study sought to examine coverage in a large representative cohort of patients. Methods We analysed retrospective data from the electronic medical records of active patients visiting 566 primary care clinics in Victoria, Australia. Pathology records were assessed to identify the proportion of patients with a record of CHB/CHC serology testing based on risk factors identified in national guidelines (ethnicity, Indigenous status, history of injecting drug use, diagnosed HIV, and/or indications of liver disease). Results Of 1,593,774 patients, 393,948 (24.7%) had an indication for testing for CHB and/or CHC, of which 150,821 (38.3%) had evidence of testing. This proportion was highest in patients with HIV (65.6%) or injecting drug use history (60.0%), and lowest for those whose Indigenous status/ethnicity indicated testing (38.2%) or with elevated liver enzymes (39.1%). The proportion with evidence of testing was only moderate among those with a cirrhosis diagnosis (48.6%) or probable cirrhosis based on laboratory testing (50.6%). Conclusions This analysis demonstrated considerable gaps in testing for CHB and CHC in a large population of patients, including many with evidence of cirrhosis, suggesting higher risk of adverse outcomes. Primary care practices should be supported to comprehensively offer testing for viral hepatitis, particularly where there is evidence of liver disease, and these findings should be used to guide future interventions.