WASHINGTON (AP) _ A rapid test may soon be ready to detect bacteria on cattle, hog and chicken carcasses within five minutes. Finding a way to make it work inside the nation's slaughterhouses will consume hours of debate.

The Agriculture Department has advertised the forthcoming test as a critical element of an improved meat and poultry system. And at a Senate Agriculture Committee hearing Friday, the department said data to prove that it works should be ready within a few weeks.

''I am confident that we are moving rapidly forward and will have the rapid test for generic bacteria ready for use by industry and government regulators,'' said Dan Laster, head of the U.S. Meat Animal Research Center in Clay Center, Neb.

But there is no law or rule to specify how a test can be used on the more than 7 billion animals slaughtered each year.

''We're not opposed to the test,'' said Sara Clarke, spokeswoman for the industry's American Meat Institute. But the industry group and others say the question is how much bacteria can be allowed before a carcass is deemed unsafe. The next question is what to do with the carcass.

The test cannot differentiate between harmless bacteria and harmful ones, like forms of salmonella and the E. coli strain. But Laster said high levels of bacteria indicate fecal contamination, one of the most harmful types.

The rapid testing means a problem can be spotted before meat leaves processing plants.

Tests can now detect specific harmful bacteria, but they take three days.

Consumer advocates say the department shouldn't wait for the rapid test to include a required test in legislation, still being completed, to improve meat and poultry inspections.

''You can sample each day's production,'' said Carol Tucker Foreman, spokeswoman for the Safe Food Coalition, an umbrella organization for several consumer and labor groups.

The law should set maximum levels of harmful bacteria and require regular sampling by government inspectors, said Foreman, who was assistant secretary of agriculture under President Carter.

The test would assure quality control and would still give time for contaminated products to be recalled. ''It takes several days to move from the end of the processing line to the supermarket shelves,'' she said.

The debate is one of several that are stalling proposed legislation and rules by the Agriculture Department.

Although no bill has been introduced, the department says it will ask Congress for power to recall contaminated products and trace contaminated birds and beasts to farms.

The department says legislation also should let it quarantine well animals bearing bacteria that may sicken humans but not animals. Quarantine rules have been oriented to animal diseases.

And it wants the bill to allow fines of up to $100,000 a day for companies.

Regulations being drafted by the department would modernize the system by relying less on visual inspections and requiring more use of science, including microbial tests, sampling and quality control.