We give new sufficient and necessary criteria guaranteeing that a hereditary graph property can be tested with a polynomial query complexity. Although both are simple combinatorial criteria, they imply almost all prior positive and negative results of this type, as well as many new ones. One striking application of our results is that every semi-algebraic graph property (e.g., being an interval graph, a unit-disc graph etc.) can be tested with a polynomial query complexity. This con firms a conjecture of Alon. The proofs combine probabilistic ideas together with a novel application of a conditional regularity lemma for matrices, due to Alon, Fischer and Newman.