Testing for the coronavirus is seen as a key strategy for preventing a surge in new cases, yet as with so many other aspects of the response to COVID-19, some states are doing a lot, others not.

Pennsylvania falls into the latter category, based on the number of tests performed per capita, according to an analysis by Johns Hopkins University. Through Tuesday, labs in the state had done 5,215 tests per 100,000 people — fewer than all but six states and Puerto Rico.

New Jersey was third-best, at 14,227 tests per 100,000, after Rhode Island and New York, while Delaware was not far behind, at 11th.

If not for Philadelphia, where testing is relatively widespread, Pennsylvania’s rate would be even lower — roughly 4,800 tests per 100,000 people, ahead of only Wyoming, Idaho, and Puerto Rico.

But how much is enough? Epidemiologists say the answer is not simple, and that in one key respect — the percent who test positive — Pennsylvania’s low level of testing may be adequate.

More on that below, but the topic has been a source of heightened controversy after President Donald Trump’s remarks at a campaign rally Saturday in Oklahoma. Without providing evidence, he said the numbers of COVID-19 cases were up in some parts of the United States not due to any real increase in illness but because the country was performing too many tests. Aides later said he was being sarcastic, but he repeated the claim Monday, insisting he was serious and saying the country was doing “too good a job” of testing.

Public health experts have overwhelmingly pushed back against that notion, arguing that robust testing is an essential tool for preventing a second wave of infection. By identifying who is positive, health officials can urge them to stay home so they do not infect others. Tests also enable health departments to perform “contact tracing” — identifying the contacts of infected people and urging them to get tested, too.

Widespread testing is not foolproof, as many COVID-19 infections are transmitted by people with no symptoms. But without it, health departments are operating in the dark.

Asked about Pennsylvania’s testing rate, Department of Health spokesperson Nate Wardle said that more testing was needed but that capacity has increased sharply since the early days of the pandemic.

Lately, the state has been testing at least 12,000 people a day, more than double the typical daily number in early May.

“We know that we need to continue to ramp up our testing capacity, and are working to do that,” Wardle said. “We have partnered with a number of companies, such as Rite Aid, CVS, Walmart through Quest [Diagnostics], etc. to ensure testing is available to all Pennsylvanians.”

The right level of testing depends in part on the percent of people that test positive, said epidemiologist Jennifer Nuzzo, senior scholar at the Johns Hopkins Center for Health Security.

If the positivity rate is high, that might mean the people who are getting tested are sicker, on average, and that the state likely is missing lots of milder cases, she said.

“People who are infected may not know they have the virus, and they are walking around spreading it,” she said.

On the flip side, a low positivity rate is likely a sign that infections are not widespread, and that a lower rate of testing is sufficient, said Nuzzo, an associate professor at the Hopkins Bloomberg School of Public Health.

“If you don’t have that many infections, you don’t have to test as much of your population,” she said.

The World Health Organization has recommended that in order for a region to reopen, its positivity rate should remain at 5% or lower for 14 days.

Lately, Pennsylvania’s statewide positivity rate has met that benchmark, hovering at about 4%.

Nuzzo said that figure seems promising, but she warned against a false sense of security, given that the rate of testing is uneven across the state. Health officials might miss “pockets of infection,” she said.

And even if a state’s rate is below 5%, it is important to watch for an increase, she said. A rise in the number of infected people means more chance the virus will be spread to others.

“It can foreshadow future cases,” she said. “Of all the metrics we measure, positivity is possibly one of the earlier indicators that we may be headed in the wrong direction.”

Staff writer Rob Tornoe contributed to this article.