President Trump on Thursday volunteered to Sean Hannity, the Fox News host, that he “very recently” took a test at Walter Reed National Military Medical Center measuring his mental acuity and “aced” it, but the White House would not say when he took it or why.Mr. Trump boasted that his success on the test surprised his doctors as he continued his attempt to make a campaign issue of whether his presumptive Democratic opponent, former Vice President Joseph R. Biden Jr., was mentally fit.“I actually took one when I — very recently, when I — when I was — the radical left were saying, is he all there? Is he all there? And I proved I was all there, because I got — I aced it. I aced the test,” Mr. Trump, 74, said in his interview with Mr. Hannity.He went on to say that Mr. Biden should also take the test.“And he should take the same exact test, a very standard test. I took it at Walter Reed Medical Center in front of doctors,” Mr. Trump said. “And they were very surprised. They said, that’s an unbelievable thing. Rarely does anybody do what you just did. But he should take that same test.”Mr. Trump described taking the test after Mr. Hannity mentioned that Mr. Biden had said he had taken several cognitive tests. The president insisted that Mr. Biden must have meant tests he took for the coronavirus and that his rival “couldn’t pass” a cognitive test.Aides to Mr. Trump did not respond to questions about what test he took, when he took it or whether they would make the results public. Over more than three years, the president has repeatedly faced questions about his own health, including why he made a mysterious visit to Walter Reed in November 2019 that White House officials later claimed was to get a jump on his annual physical.After Mr. Trump’s most recent examination, Dr. Sean Conley, the White House physician, who examined him, said that “the data indicates the president remains healthy.”But Dr. Conley’s summary was not the customary report Mr. Trump and other presidents have released immediately after an annual physical exam. Rather than one examination, the summary was based on an unknown number of medical appointments that included the visit to Walter Reed in November, and another from a checkup conducted in April at the White House.After his annual physical in 2018, the White House physician at the time, Dr. Ronny L. Jackson, said that the president had received a score of 30 out of 30 on the Montreal Cognitive Assessment, a test that hospitals including Walter Reed use to screen for “mild cognitive dysfunction,” and that there was “no reason whatsoever to think the president has any issues whatsoever with his thought processes.”Dr. Jackson said then that Mr. Trump had asked to take the test.Since Mr. Biden emerged as his election opponent, the president and his advisers have tried to hammer home a message about whether, at age 77 and prone to gaffes, Mr. Biden is mentally capable of being president.Andrew Bates, a spokesman for Mr. Biden, said the accusations were a product of Mr. Trump’s standing in the polls. “If the Trump campaign believes the answer to their precipitously dropping support is to triple-down on yet another smear that’s backfired on them for over a year,” he said, “then frankly, maybe it’s not just Donald Trump who’s missing something — but also his campaign’s ‘strategists’ who somehow still haven’t grasped that the ‘project, commit a self-own, then repeat’ model is accelerating their free fall.”Private Republican polling has shown the attacks on Mr. Biden’s cognitive state have not done much to move the needle with voters, according to people who described the details of the surveys. And Mr. Trump is a difficult messenger for an attack on Mr. Biden as his own health has come under scrutiny.That included an episode during a speech at West Point last month when the president had difficulty bringing a water glass to his mouth with one hand and then walked gingerly down a ramp to exit the stage.In response to the questions that followed, Mr. Trump lashed out on Twitter, insisting the ramp was slippery, and then he devoted more than 10 minutes of his rally in Tulsa, Okla., a week later to defend himself and insist he was healthy. The president described it to the crowd as a “journey” down the ramp and insisted the ramp was as slick as an ice-skating rink.“I looked very handsome,” he said. “I wouldn’t want to run down the whole thing because the fall there would be definitely bad. So I took these little steps — I ran down the last 10.”The video did not show Mr. Trump going any faster until the final three steps.