  Let $\mathcal{P}$ be a property of function $\mathbb{F}_p^n \to \{0,1\}$ for
a fixed prime $p$. An algorithm is called a tester for $\mathcal{P}$ if, given
a query access to the input function $f$, with high probability, it accepts
when $f$ satisfies $\mathcal{P}$ and rejects when $f$ is "far" from satisfying
$\mathcal{P}$. In this paper, we give a characterization of affine-invariant
properties that are (two-sided error) testable with a constant number of
queries. The characterization is stated in terms of decomposition theorems,
which roughly claim that any function can be decomposed into a structured part
that is a function of a constant number of polynomials, and a pseudo-random
part whose Gowers norm is small. We first give an algorithm that tests whether
the structured part of the input function has a specific form. Then we show
that an affine-invariant property is testable with a constant number of queries
if and only if it can be reduced to the problem of testing whether the
structured part of the input function is close to one of a constant number of
candidates.
