The House Banking subcommittee on housing yesterday approved a compromise version of the Reagan administration's fair-housing program, retaining $4 million to support private groups' use of "testing" to detect discrimination.

Testing involves sending out pairs of people who are similar in all respects except one, such as race, to try to rent or buy housing. If a white tester is told that a unit is available and a nonwhite tester is told it is not, that can be used as evidence of discrimination.

The administration had proposed a provision that would allow the Housing and Urban Development Department to give grants to private groups to run testing programs. Subcommittee chairman Henry B. Gonzalez (D-Tex.) included that proposal in the fiscal 1986 housing authorization bill.

The plan came under fire from the National Association of Realtors, which contended that while it did not oppose testing in principle, it feared that in the absence of HUD regulations private groups would operate out of control. In the bipartisan compromise agreed to yesterday -- and strongly endorsed by HUD Secretary Samuel R. Pierce Jr. -- HUD will be required to draw up regulations and submit them to the Senate and House Banking Committees for approval before any of the $4 million can be spent.