Genetic testing is the primary method for detecting BRCA1 and BRCA2 mutations. This involves a blood or saliva test that analyzes DNA to identify mutations. People with a family history of breast or ovarian cancer are often advised to undergo genetic counseling and testing to assess their risk.